通过浏览器扩展添加表值
我在网站表中有一组数据,该表有多个页面,我需要解析并添加特定字段的值,特别是价格字段和库存字段。 我无权访问代码或数据库。有谁知道 Chrome 或 Firefox 中是否有扩展程序可以促进此类功能?这是我需要的数据示例:
我想要一个非常简单的摘要例如“库存总价:$500.00”。我什至不介意它是否是每页的,我必须写下每个新的总数并自己将它们加起来。我精通 jQuery 等,所以如果我能自己写这个,我什至不介意指向那个方向的指针。但它必须是一个扩展,因为我无法直接访问该页面。
编辑:greasemonkey 脚本可以做到这一点吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您精通 jQuery,并且知道如何从该表中提取数据并进行自己的计算,那么这对您来说将非常容易!请参阅文档,它包含执行此类操作所需的所有信息:
http:// /code.google.com/chrome/extensions/getstarted.html
一种方法
如果您希望在访问该页面时始终显示总计,那么您可以使用 内容脚本。内容脚本世界将直接与该页面的 DOM 通信,因此您可以使用 jQuery 来完成您的任务。其骨架为:
manifest.json
cs.js
另一种方法,
如果您只想在单击浏览器上的按钮时显示总计。您可以使用浏览器操作。您需要一个后台页面来监听您点击该浏览器操作的情况。基本上,其框架是:
manifest.json
background.html
cs.js
就是这样,请参阅文档以获取更多帮助,上面的代码未经测试,所以如果东西不能立即工作,请不要感到惊讶:)
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
cs.js
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
background.html
cs.js
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 :)
您可以尝试类似的操作,并将其另存为书签:
这未经测试,但应该为您提供总体思路。使用小书签生成器(有 很多),放入 JavaScript,并将其另存为书签。然后,只需在查看任何页面时单击小书签链接,您就会收到显示总数的警报。可能的增强功能包括使用 URL 作为键将值保存到 localStorage(这样您就不会重复,并且可以跟踪累积总数)。
You can try something like this, and save it as a bookmarklet:
This is not tested, but should give you the general idea. Use a bookmarklet generator (there are many), drop in your JavaScript, and save it as a bookmarklet. Then just click the bookmarklet link while viewing any page, and you'll get an alert displaying the total. Possible enhancements include saving the value to localStorage using the URL as a key (so you don't duplicate, and can track cumulative totals).