How to make Google Chrome extension to run jQuery Script -


i have jquery script:

$('[id^=changesetlist] tr').each(function () {     var sid = $(this).attr('sid');     $(this).find('td span.changesetdescription').append('<span class="csethash">' + sid + '</span>').css('color','#777'); }); 

i want run when visit kilnhg.com.

i put in in kiln_hash.user.js file , installed chrome doesn't anything.

i think might because requires jquery.

i have read few tutorials , looks might need create manifest.json file , put , .user.js file zip file .crx extension.

i still not know need put in manifest file.

how can work?


update

i created manifest.json file:

{   "name": "kiln hash",   "version": "1.0.1",   "description": "show hash in changeset list in kiln",   "content_scripts": [     {       "matches": ["https://*.kilnhg.com/*"],       "js": ["jquery.js"]     }   ],   "background_page": "bg.html" } 

i include jquery.js file (version 1.4.2) , bg.html file:

<!doctype html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <script src="jquery.js"></script>  <script>  $(document).ready(function(){     $(hash_link).click(function(){         addhash();         return false;     }); }); function addhash() {     $('[id^=changesetlist] tr').each(function () {         var sid = $(this).attr('sid');         $(this).find('td span.changesetdescription').append('<span class="csethash">' + sid + '</span>').css('color','#777');     }); }  </script>  <title>untitled document</title> </head>  <body> <a id="hash_link" href="#">add hash</a> </body> </html> 

i packaged in zip .crx extension , when drag file chrome asks me if want install yes. tells me "bad magic number"

so go chrome developer dashboard , upload zip, accepts it, makes pay $5 upload , installs. still nothing.

you not might need manifest, manifest absolutely necessary part of extension. hate that, need read little more extension structure first, , questions answered.

(i can provide answer if like, more beneficial read links yourself, it's described , explained there in great details)

update

to locally install extension don't need archive it, go extensions chrome://extensions/, click "developer mode", "load unpacked extension" button, , point extension folder.

if want inject script page need use what's called "content scripts". manifest should this:

{   "name": "kiln hash",   "version": "1.0.1",   "description": "show hash in changeset list in kiln",   "content_scripts": [     {       "matches": ["https://*.kilnhg.com/*"],       "js": ["jquery.js", "content_script.js"]     }   ] } 

content_script.js:

$('[id^=changesetlist] tr').each(function () {     var sid = $(this).attr('sid');     $(this).find('td span.changesetdescription').append('<span class="csethash">' + sid + '</span>').css('color','#777'); }); 

this content script run on specified domain after dom loaded , jquery injected.

you don't need background page this.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -