aboutsummaryrefslogtreecommitdiff
path: root/viewtube.js
diff options
context:
space:
mode:
Diffstat (limited to 'viewtube.js')
-rw-r--r--viewtube.js71
1 files changed, 9 insertions, 62 deletions
diff --git a/viewtube.js b/viewtube.js
index 2a0f7b0..61ffaa1 100644
--- a/viewtube.js
+++ b/viewtube.js
@@ -272,52 +272,6 @@
browser.storage.local.set(pair);
}
- function showMyMessage(cause, content) {
- var myScriptLogo = createMyElement('div', userscript, '', '', '');
- styleMyElement(myScriptLogo, {margin: '0px auto', padding: '10px', color: '#666666', fontSize: '24px', textAlign: 'center', textShadow: '#FFFFFF -1px -1px 2px'});
- var myScriptMess = createMyElement('div', '', '', '', '');
- styleMyElement(myScriptMess, {border: '1px solid #F4F4F4', margin: '5px auto 5px auto', padding: '10px', backgroundColor: '#FFFFFF', color: '#AD0000', textAlign: 'center'});
- if (cause == '!player') {
- var myScriptAlert = createMyElement('div', '', '', '', '');
- styleMyElement(myScriptAlert, {position: 'absolute', top: '30%', left: '35%', border: '1px solid #F4F4F4', borderRadius: '3px', padding: '10px', backgroundColor: '#FFFFFF', fontSize: '14px', textAlign: 'center', zIndex: '99999'});
- myScriptAlert.appendChild(myScriptLogo);
- var myNoPlayerMess = 'Couldn\'t get the player element. Please report it <a href="' + contact + '" style="color:#00892C">here</a>.';
- modifyMyElement(myScriptMess, 'div', myNoPlayerMess, false);
- myScriptAlert.appendChild(myScriptMess);
- var myScriptAlertButton = createMyElement('div', 'OK', 'click', 'close', myScriptAlert);
- styleMyElement(myScriptAlertButton, {width: '100px', border: '3px solid #EEEEEE', borderRadius: '5px', margin: '0px auto', backgroundColor: '#EEEEEE', color: '#666666', fontSize: '18px', textAlign: 'center', textShadow: '#FFFFFF -1px -1px 2px', cursor: 'pointer'});
- myScriptAlert.appendChild(myScriptAlertButton);
- page.body.appendChild(myScriptAlert);
- }
- else if (cause == '!thumb') {
- var myNoThumbMess = '<br><br>Couldn\'t get the thumbnail for this video. Please report it <a href="' + contact + '" style="color:#00892C">here</a>.';
- modifyMyElement(player['playerContent'], 'div', myNoThumbMess, false);
- }
- else {
- myPlayerWindow.appendChild(myScriptLogo);
- if (cause == '!content') {
- var myNoContentMess = 'Couldn\'t get the videos content. Please report it <a href="' + contact + '" style="color:#00892C">here</a>.';
- modifyMyElement(myScriptMess, 'div', myNoContentMess, false);
- }
- else if (cause == '!videos') {
- var myNoVideosMess = 'Couldn\'t get any video. Please report it <a href="' + contact + '" style="color:#00892C">here</a>.';
- modifyMyElement(myScriptMess, 'div', myNoVideosMess, false);
- }
- else if (cause == '!support') {
- var myNoSupportMess = 'This video uses the RTMP protocol and is not supported.';
- modifyMyElement(myScriptMess, 'div', myNoSupportMess, false);
- }
- else if (cause == 'embed') {
- var myEmbedMess = 'This is an embedded video. You can watch it <a href="' + content + '" style="color:#00892C">here</a>.';
- modifyMyElement(myScriptMess, 'div', myEmbedMess, false);
- }
- else if (cause == 'other') {
- modifyMyElement(myScriptMess, 'div', content, false);
- }
- myPlayerWindow.appendChild(myScriptMess);
- }
- }
-
// =====YouTube===== //
/* Redirect Categories */
@@ -366,9 +320,7 @@
/* Get Player Window */
var ytPlayerWindow = document.querySelector("#player");
- if (!ytPlayerWindow) {
- showMyMessage('!player');
- }
+ if (!ytPlayerWindow) console.log("Couldn't get the player element.");
else {
/* Get Video Thumbnail */
var ytVideoThumb = getMyContent(page.url, 'link\\s+itemprop="thumbnailUrl"\\s+href="(.*?)"', false);
@@ -572,8 +524,9 @@
ytPlayer();
}
else {
- if (ytVideosContent.indexOf('conn=rtmp') != -1) showMyMessage('!support');
- else showMyMessage('!videos');
+ if (ytVideosContent.indexOf("conn=rtmp") != -1)
+ console.log("This video uses the RTMP protocol and is not supported.");
+ else console.log("Couldn't get any video.");
}
}
@@ -636,23 +589,19 @@
ytDecryptFunction();
ytVideos();
}
- else {
- showMyMessage('other', 'Couldn\'t get the signature content. Please report it <a href="' + contact + '" style="color:#00892C">here</a>.');
- }
+ else console.log("Couldn't get the signature content.");
};
oReq.onerror = function() {
- showMyMessage('other', 'Couldn\'t make the request. Make sure your browser user scripts extension supports cross-domain requests.');
+ console.log("Couldn't make the request. Make sure your browser user scripts extension supports cross-domain requests.");
};
oReq.send();
}
catch(e) {
- showMyMessage('other', 'Couldn\'t make the request. Make sure your browser user scripts extension supports cross-domain requests.');
+ console.log("Couldn't make the request. Make sure your browser user scripts extension supports cross-domain requests.");
}
}
}
- else {
- showMyMessage('other', 'Couldn\'t get the signature link. Please report it <a href="' + contact + '" style="color:#00892C">here</a>.');
- }
+ else console.log("Couldn't get the signature link.");
}
else {
ytVideos();
@@ -684,9 +633,7 @@
}
}
}
- else {
- showMyMessage('!content');
- }
+ else console.log("Couldn't get the videos content.");
}
}