User:Eleanorg/Thematic1.1/control opacity using jQuery plugin: Difference between revisions

From XPUB & Lens-Based wiki
(Created page with "This Chrome plugin changes the opacity of web pages with a single line of jQuery. Eventually the extension will be plugged into my python script, which will return a dynamic opac...")
 
Line 10: Line 10:
===manifest.json===
===manifest.json===
Note that jQuery is stored locally as jquery.js, and this file points to the actual code which is stored in contentscript.js:
Note that jQuery is stored locally as jquery.js, and this file points to the actual code which is stored in contentscript.js:
<source lang=json>
<source lang=javascript>
{
{
   "name": "traceroute1",
   "name": "traceroute1",

Revision as of 19:34, 10 December 2011

This Chrome plugin changes the opacity of web pages with a single line of jQuery. Eventually the extension will be plugged into my python script, which will return a dynamic opacity value based on the number of hops in that webpage's traceroute.

It follows the basic Chrome extension pattern of being made up of a manifest.json file (containing metadata) and a .js file containing the actual code. In this case, jQuery is also stored locally in jquery.js.

contentscript.js

 $("body").css({ opacity: 0.2 });

manifest.json

Note that jQuery is stored locally as jquery.js, and this file points to the actual code which is stored in contentscript.js:

{
  "name": "traceroute1",
  "version": "1.0",
  "description": "changes the opacity of web pages",
  "browser_action": {
    "default_icon": "icon.png"
  },
  "permissions": ["history"],
  "content_scripts": [
    {
      "matches": ["*://*/*"],
      "js": ["jquery.js", "contentscript.js"],
      "run_at": "document_end"
    }
  ]
}