Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Its a sandbox thing I guess, your not allowed to execute scripts from the page so i guess plugins count to.<br> That known its just a matter of playing outside the sandbox.... </p> <p><strong>script.js</strong></p> <pre><code>var customEvent = document.createEvent('Event'); customEvent.initEvent('JPlayerNotify', true, true); function notify() { document.getElementById('communicationDIV').innerText='notify'; document.getElementById('communicationDIV').dispatchEvent(customEvent); } // Utitlity function to append some js into the page, so it runs in the context of the page function appendScript(file) { var script = document.createElement('script'); script.setAttribute("type", "application/javascript"); script.setAttribute("src", chrome.extension.getURL(file)); document.head.appendChild(script); } appendScript("JPlayer.js"); // had to wait for a bit for the page to be ready (dialup and all), you wont need to do the setTimeout setTimeout("notify()",3500); </code></pre> <p><strong>JPlayer.js</strong></p> <pre><code>var notify_node = document.createElement('div'); notify_node.id = 'communicationDIV'; document.documentElement.appendChild(notify_node); notify_node.addEventListener('JPlayerNotify', function() { var eventData = notify_node.innerText; if (eventData=='notify'){ $("#jplayer").jPlayer('play', 0); } }); </code></pre> <p><strong>manifest.json</strong></p> <pre><code>{ "name": "JPlayerNotify", "version": "0.5.0", "description": "JPlayerNotify", "content_scripts" : [ { "matches": ["http://chat.stackoverflow.com/rooms/*"], "js" : ["script.js"], "run_at" : "document_idle", "all_frames" : false } ], "permissions": [ "http://stackoverflow.com/*", "https://stackoverflow.com/*", "http://*.stackoverflow.com/*", "https://*.stackoverflow.com/*" ] } </code></pre> <p>You can see some stuff on communicating with the page here... <a href="http://code.google.com/chrome/extensions/content_scripts.html" rel="nofollow">http://code.google.com/chrome/extensions/content_scripts.html</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload