diff options
author | Arun Isaac | 2017-08-01 23:24:11 +0530 |
---|---|---|
committer | Arun Isaac | 2017-08-01 23:24:11 +0530 |
commit | 143d46d79b098c722ecf82201e81ba334c47ed30 (patch) | |
tree | 7bccb23020e1f0a25ad43c170fe842916f254801 | |
parent | 8a6feadcc6cc170a45b194a330e7a4064fee99d4 (diff) | |
download | youtube-noscript-shim-143d46d79b098c722ecf82201e81ba334c47ed30.tar.gz youtube-noscript-shim-143d46d79b098c722ecf82201e81ba334c47ed30.tar.lz youtube-noscript-shim-143d46d79b098c722ecf82201e81ba334c47ed30.zip |
Remove browser storage of settings.
* viewtube.js (createMyPlayer): Remove browser storage of settings.
(setMyOptions): Remove function.
(createElement, createVideoElement): Change function signature.
* manifest.json (permissions): Remove "storage".
-rw-r--r-- | manifest.json | 2 | ||||
-rw-r--r-- | viewtube.js | 68 |
2 files changed, 25 insertions, 45 deletions
diff --git a/manifest.json b/manifest.json index 3341b49..bc16745 100644 --- a/manifest.json +++ b/manifest.json @@ -5,8 +5,6 @@ "description": "Use YouTube with NoScript", - "permissions": ["storage"], - "content_scripts": [ { "matches": ["https://youtube.com/*", "https://www.youtube.com/*"], diff --git a/viewtube.js b/viewtube.js index f20007d..7b45b05 100644 --- a/viewtube.js +++ b/viewtube.js @@ -47,57 +47,45 @@ // ==========Functions========== // - function createElement (type, attributes, ...children) { + function createElement (type, attributes, parent) { var element = document.createElement(type); for (var key in attributes) { if (key == 'innerHTML') element.innerHTML = attributes[key]; else element.setAttribute(key, attributes[key]); } - for (var child in children) - element.appendChild(child); + if (parent) parent.appendChild(element); return element; } - function createVideoElement (attributes, ...children) { - return createElement("video", Object.assign({controls: "controls", autoplay: "autoplay", volume: 0.8}, attributes)); + function createVideoElement (attributes, parent, ...children) { + return createElement.apply(null, ["video", Object.assign({controls: "controls", autoplay: "autoplay", volume: 0.8}, attributes), parent].concat(children)); } function createMyPlayer() { - /* Get My Options */ - function onGot(item) { - Object.assign(option, item); - - /* The Panel */ - player['playerPanel'] = createElement('div'); - player['playerWindow'].appendChild(player['playerPanel']); - - /* Panel Video Menu */ - player["videoMenu"] = createElement("select", {title: "Select the video format for playback"}); - player["videoMenu"].addEventListener('change', function() { - player['videoPlay'] = this.value; - playMyVideo(); - }, false); - player['playerPanel'].appendChild(player['videoMenu']); - for (var videoCode in player['videoList']) { - player["videoItem"] = createElement("option", {value: videoCode, innerHTML: videoCode}); - if (videoCode.indexOf('Video') != -1 || videoCode.indexOf('Audio') != -1) - player["videoItem"].classList.add("audio-video-only"); - if (player['videoList'][videoCode] == 'DASH') - player["videoItem"].classList.add("dash"); - player['videoMenu'].appendChild(player['videoItem']); - if (videoCode == 'Direct Video Link') - player["videoItem"].classList.add("direct-video-link"); - } - - /* The Content */ - player['playerContent'] = createElement('div'); - player['playerWindow'].appendChild(player['playerContent']); + /* The Panel */ + player["playerPanel"] = createElement("div", {}, player["playerWindow"]); - /* Play My Video */ + /* Panel Video Menu */ + player["videoMenu"] = createElement("select", {title: "Select the video format for playback"}, player["playerPanel"]); + player["videoMenu"].addEventListener('change', function() { + player['videoPlay'] = this.value; playMyVideo(); + }, false); + for (var videoCode in player['videoList']) { + player["videoItem"] = createElement("option", {value: videoCode, innerHTML: videoCode}, player["videoMenu"]); + if (videoCode.indexOf('Video') != -1 || videoCode.indexOf('Audio') != -1) + player["videoItem"].classList.add("audio-video-only"); + if (player['videoList'][videoCode] == 'DASH') + player["videoItem"].classList.add("dash"); + if (videoCode == 'Direct Video Link') + player["videoItem"].classList.add("direct-video-link"); } - promise = browser.storage.local.get(Object.keys(option)); - promise.then(onGot, onGot); + + /* The Content */ + player["playerContent"] = createElement("div", {}, player["playerWindow"]); + + /* Play My Video */ + playMyVideo(); } function playDASHwithHTML5() { @@ -178,12 +166,6 @@ } } - function setMyOptions(key, value) { - var pair = {}; - pair[key] = value; - browser.storage.local.set(pair); - } - // =====YouTube===== // // Add stylesheet |