通过浏览器扩展添加表格值 [英] Add table values through browser extension

查看:376
本文介绍了通过浏览器扩展添加表格值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站表中的一组数据,有多个页面,我需要解析和添加特定字段的值,特别是价格字段和库存字段。 我无权访问代码或数据库。有人知道Chrome或Firefox中是否有扩展功能可以促进此类功能?这里是我需要的数据的一个例子:



我想要一个非常简单的总结,比如总库存价格:$ 500.00。我甚至不介意这是否是每页,我不得不写下每一个新的总和,并把它们自己加起来。我精通jQuery等,如果我可以自己写这个,我甚至不会介意这个方向的指针。这将是一个扩展,虽然我没有直接访问该页面。

编辑:可以一个greasemonkey脚本做到这一点如果你精通jQuery,并且知道如何从表中提取数据并进行自己的计算,那么你可以使用jQuery,那么这将是超级容易的你做!请参阅文档,其中包含您需要执行此类操作的所有信息:

http://code.google.com/chrome/extensions/getstarted.html



One Way



如果您希望在访问该页面时始终显示总计,则可以使用内容脚本。内容脚本世界将直接与该页面的DOM通信,所以你可以使用jQuery并做你的事情。骨架为:
$ b

manifest.json

 < 
name:Content Script test,
version:0.1,
description:Content Script test,
content_scripts:[
{
matches:[http://www.website.com/*],
js:[jquery-1.4.2。
run_at:document_start,
all_frames:true
}
]
}

cs.js

  //您的jQuery 



另一种方式



只有当您点击浏览器上的按钮才能显示总计。您可以使用浏览器操作。当您点击该浏览器操作时,您需要后台页面进行收听。基本上,这样的骨架将是:
$ b

manifest.json



<$ p $内容脚本测试,
name:浏览器动作测试,
version:0.1,
description b $ bbackground_page:background.html,
browser_action:{
default_icon:icon19.png,
default_title:浏览器操作测试
},
permissions:[tabs,http://www.website.com/*]
}




$ b

 chrome.browserAction.onClicked.addListener(function(tab){
chrome.tabs.executeScript(tab.id,{file:'jquery-1.4.2.min.js'});
chrome。 tabs.executeScript(tab.id,{file:'cs.js'});
});

cs.js

  //您的jQuery 

就是这样请参阅文档以获得更多帮助,上面的代码没有经过测试,所以不要惊讶,如果东西不开箱即用)

I have a set of data in a website table that has multiple pages that I need to parse and add the values of a certain field, specifically price field and an inventory field. I don't have access to the code or database. Does anyone know if there is an extension in Chrome or Firefox that can facilitate this type of functionality? Here is an example of the data I need:

I would like a very simple summary like "Total Inventory Price: $500.00". I wouldn't even mind if it were per page and I had to write down each new total and add them up myself. I am proficient in jQuery and such so if I could somehow write this myself, I wouldn't even mind a pointer in that direction. It would have to be an extension though as I don't have direct access to the page.

Edit: Could a greasemonkey script do this?

解决方案

If you're proficient in jQuery, and know how to extract the data from that table and do your own calculations, then it will be super easy for you to do! Please refer to the documentation, it has all the information you need to do such thing:

http://code.google.com/chrome/extensions/getstarted.html

One Way

If you want this to always show the totals when you visit that page, then you can use a content script. The content script world will have direct communication to the DOM of that page, so you can use jQuery and do your thing. Skeleton for that would be:

manifest.json

{
  "name": "Content Script test",
  "version": "0.1",
  "description": "Content Script test",
  "content_scripts": [
    {
      "matches": ["http://www.website.com/*"],
      "js": [ "jquery-1.4.2.min.js", "cs.js" ],
      "run_at": "document_start",
      "all_frames": true
    }
  ]
}

cs.js

// Your jQuery

Another Way

If you want to show the totals only when you click on a button on the browser. You can use a browser action. You would need a background page to listen when you click on that browser action. Basically, the skeleton for that would be:

manifest.json

{
  "name": "Browser Action test",
  "version": "0.1",
  "description": "Content Script test",
  "background_page": "background.html",
    "browser_action": {
    "default_icon": "icon19.png",
    "default_title": "Browser Action Test"
  },
  "permissions": [ "tabs", "http://www.website.com/*" ]
}

background.html

chrome.browserAction.onClicked.addListener(function(tab) {
  chrome.tabs.executeScript(tab.id, {file: 'jquery-1.4.2.min.js'});
  chrome.tabs.executeScript(tab.id, {file: 'cs.js'});
});

cs.js

// Your jQuery

That's it, please refer to the documentation for more assistance, the code above is untested, so don't be surprised if stuff don't work right out of the box :)

这篇关于通过浏览器扩展添加表格值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆