--- /dev/null
+chrome.runtime.onConnect.addListener(function(port) {
+ console.assert(port.name == "contentscript");
+ port.onMessage.addListener(function(msg) {
+ if (msg.contentscript == "Hello background!") {
+ console.log('from contentscript : ' + msg.contentscript);
+ port.postMessage({background: "Hello contentscript!"});
+ }
+ });
+});
--- /dev/null
+var port = chrome.runtime.connect({name: "contentscript"});
+port.postMessage({contentscript: "Hello background!"});
+port.onMessage.addListener(function(msg) {
+ if (msg.background == "Hello contentscript!") {
+ console.log('from background : ' + msg.background);
+ }
+});
+
+var theater = 49;
+var ads = 50;
+var toggle = 0;
+
+window.onkeydown = function() {
+ console.log("keycode : ", event.keyCode);
+
+ var key = event.keyCode;
+
+ if (key == theater) {
+
+ if (document.getElementById("view")) {
+ var view = document.getElementById("view");
+ document.getElementById("con3").removeChild(view);
+ }
+ else {
+ var element = document.createElement("div");
+ element.id = 'view';
+
+ var txt = document.createTextNode("Theater mode");
+ element.appendChild(txt);
+
+ var attribute = document.createAttribute("style");
+ attribute.nodeValue = "background-color:rgb(0, 0, 0); position: absolute; top:0px; left:0px; width:"+screen.availWidth+"px; height:"+screen.availHeight+"px; z-index:1; color:white; font-size:30px; font-weight:bold;";
+ element.setAttributeNode(attribute);
+
+ document.getElementById("con3").appendChild(element);
+
+ var videoDiv = document.getElementById("video1");
+ var attribute = document.createAttribute("style");
+
+ attribute.nodeValue = "position:absolute; z-index:2;";
+ videoDiv.setAttributeNode(attribute);
+ }
+ }
+ else if (key == ads) {
+ if (toggle == 1) {
+ document.getElementById("con3").style.backgroundImage = 'url(img/11.jpg)';
+ document.getElementById("con5").style.backgroundImage = 'url(img/12.jpg)';
+ toggle = 0;
+ }
+ else {
+ document.getElementById("con3").style.backgroundImage = 'url(img/13.jpg)';
+ document.getElementById("con5").style.backgroundImage = 'url(img/13.jpg)';
+ toggle = 1;
+ }
+ }
+}
--- /dev/null
+{
+ "name": "adv_off",
+ "description": "Block ads and make your videos viewable in theater mode",
+ "version": "1.0",
+ "background": {
+ "scripts": ["background.js"],
+ "persistent": false
+ },
+ "content_scripts": [
+ {
+ "matches": [
+ "<all_urls>"
+ ],
+ "js": ["contentscript.js"]
+ }
+ ],
+ "browser_action": {
+ "default_title": "adv_off"
+ },
+ "manifest_version": 2
+}