summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--manifest.json2
-rw-r--r--viewtube.js68
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