[WRT] Add adv-off extension 52/151752/4
authormin7.choi <min7.choi@samsung.com>
Thu, 21 Sep 2017 11:03:49 +0000 (20:03 +0900)
committerjaekuk lee <juku1999@samsung.com>
Tue, 31 Oct 2017 00:40:06 +0000 (00:40 +0000)
This extension is a sample example that allows app
to block ads and view your movie in movie mode.

Change-Id: Iaba00ccae3e435d0ab08b7cea7807a927001b30e
Signed-off-by: min7.choi <min7.choi@samsung.com>
wrt/wrt_support/extensions_repo/adv_off/background.js [new file with mode: 0755]
wrt/wrt_support/extensions_repo/adv_off/contentscript.js [new file with mode: 0755]
wrt/wrt_support/extensions_repo/adv_off/manifest.json [new file with mode: 0755]

diff --git a/wrt/wrt_support/extensions_repo/adv_off/background.js b/wrt/wrt_support/extensions_repo/adv_off/background.js
new file mode 100755 (executable)
index 0000000..fdc3e97
--- /dev/null
@@ -0,0 +1,9 @@
+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!"});
+    }
+  });
+});
diff --git a/wrt/wrt_support/extensions_repo/adv_off/contentscript.js b/wrt/wrt_support/extensions_repo/adv_off/contentscript.js
new file mode 100755 (executable)
index 0000000..7eb09e1
--- /dev/null
@@ -0,0 +1,56 @@
+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;
+       }
+  }
+}
diff --git a/wrt/wrt_support/extensions_repo/adv_off/manifest.json b/wrt/wrt_support/extensions_repo/adv_off/manifest.json
new file mode 100755 (executable)
index 0000000..0958e77
--- /dev/null
@@ -0,0 +1,21 @@
+{
+  "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
+}