aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesús <heckyel@hyperbola.info>2020-07-05 16:54:17 -0500
committerJesús <heckyel@hyperbola.info>2020-07-05 16:54:17 -0500
commitcca78b770c0cd23727985ac1f4ecc5d35fc51774 (patch)
treed997de9edc2d2f09d0ba3f53810433018fa28973
parentf2c9969b12da6493f9fcba75e747a2b402d637ab (diff)
downloadbook-cca78b770c0cd23727985ac1f4ecc5d35fc51774.tar.lz
book-cca78b770c0cd23727985ac1f4ecc5d35fc51774.tar.xz
book-cca78b770c0cd23727985ac1f4ecc5d35fc51774.zip
scripts-greasemonkey: Improve log message
* fix change indent-spaces: 4 to 2
-rw-r--r--scripts-greasemonkey/fix_input_dark_theme.user.js2
-rw-r--r--scripts-greasemonkey/gm4-polyfill.js162
-rw-r--r--scripts-greasemonkey/instagram_to_bibliogram.user.js26
-rw-r--r--scripts-greasemonkey/invidio_embed.user.js92
-rw-r--r--scripts-greasemonkey/invidio_proxy_mode.user.js45
-rw-r--r--scripts-greasemonkey/twitter_to_nitter.user.js26
-rw-r--r--scripts-greasemonkey/youtube_to_invidious.user.js134
7 files changed, 241 insertions, 246 deletions
diff --git a/scripts-greasemonkey/fix_input_dark_theme.user.js b/scripts-greasemonkey/fix_input_dark_theme.user.js
index de38a3e..f961c4b 100644
--- a/scripts-greasemonkey/fix_input_dark_theme.user.js
+++ b/scripts-greasemonkey/fix_input_dark_theme.user.js
@@ -6,7 +6,7 @@
// @homepageURL https://libregit.spks.xyz/heckyel/book/src/branch/master/scripts-greasemonkey
// @include *
// @grant none
-// @version 0.0.1
+// @version 0.0.2
// @license GPL version 3 or any later version::: https://www.gnu.org/licenses/gpl-3.0.html
// ==/UserScript==
/* jshint esversion: 6 */
diff --git a/scripts-greasemonkey/gm4-polyfill.js b/scripts-greasemonkey/gm4-polyfill.js
index 32d79cd..ff0ebdc 100644
--- a/scripts-greasemonkey/gm4-polyfill.js
+++ b/scripts-greasemonkey/gm4-polyfill.js
@@ -25,106 +25,106 @@
*/
if (typeof GM == 'undefined') {
- this.GM = {};
+ this.GM = {};
}
if (typeof GM_addStyle == 'undefined') {
- this.GM_addStyle = (aCss) => {
- 'use strict';
- let head = document.getElementsByTagName('head')[0];
- if (head) {
- let style = document.createElement('style');
- style.setAttribute('type', 'text/css');
- style.textContent = aCss;
- head.appendChild(style);
- return style;
- }
- return null;
- };
+ this.GM_addStyle = (aCss) => {
+ 'use strict';
+ let head = document.getElementsByTagName('head')[0];
+ if (head) {
+ let style = document.createElement('style');
+ style.setAttribute('type', 'text/css');
+ style.textContent = aCss;
+ head.appendChild(style);
+ return style;
+ }
+ return null;
+ };
}
if (typeof GM_registerMenuCommand == 'undefined') {
- this.GM_registerMenuCommand = (caption, commandFunc, accessKey) => {
- if (!document.body) {
- if (document.readyState === 'loading'
- && document.documentElement && document.documentElement.localName === 'html') {
- new MutationObserver((mutations, observer) => {
- if (document.body) {
- observer.disconnect();
- GM_registerMenuCommand(caption, commandFunc, accessKey);
- }
- }).observe(document.documentElement, {childList: true});
- } else {
- console.error('GM_registerMenuCommand got no body.');
- }
- return;
- }
- let contextMenu = document.body.getAttribute('contextmenu');
- let menu = (contextMenu ? document.querySelector('menu#' + contextMenu) : null);
- if (!menu) {
- menu = document.createElement('menu');
- menu.setAttribute('id', 'gm-registered-menu');
- menu.setAttribute('type', 'context');
- document.body.appendChild(menu);
- document.body.setAttribute('contextmenu', 'gm-registered-menu');
- }
- let menuItem = document.createElement('menuitem');
- menuItem.textContent = caption;
- menuItem.addEventListener('click', commandFunc, true);
- menu.appendChild(menuItem);
- };
+ this.GM_registerMenuCommand = (caption, commandFunc, accessKey) => {
+ if (!document.body) {
+ if (document.readyState === 'loading'
+ && document.documentElement && document.documentElement.localName === 'html') {
+ new MutationObserver((mutations, observer) => {
+ if (document.body) {
+ observer.disconnect();
+ GM_registerMenuCommand(caption, commandFunc, accessKey);
+ }
+ }).observe(document.documentElement, {childList: true});
+ } else {
+ console.error('GM_registerMenuCommand got no body.');
+ }
+ return;
+ }
+ let contextMenu = document.body.getAttribute('contextmenu');
+ let menu = (contextMenu ? document.querySelector('menu#' + contextMenu) : null);
+ if (!menu) {
+ menu = document.createElement('menu');
+ menu.setAttribute('id', 'gm-registered-menu');
+ menu.setAttribute('type', 'context');
+ document.body.appendChild(menu);
+ document.body.setAttribute('contextmenu', 'gm-registered-menu');
+ }
+ let menuItem = document.createElement('menuitem');
+ menuItem.textContent = caption;
+ menuItem.addEventListener('click', commandFunc, true);
+ menu.appendChild(menuItem);
+ };
}
if (typeof GM_getResourceText == 'undefined') {
- this.GM_getResourceText = (aRes) => {
- 'use strict';
- return GM.getResourceUrl(aRes)
- .then(url => fetch(url))
- .then(resp => resp.text())
- .catch(function(error) {
- GM.log('Request failed', error);
- return null;
- });
- };
+ this.GM_getResourceText = (aRes) => {
+ 'use strict';
+ return GM.getResourceUrl(aRes)
+ .then(url => fetch(url))
+ .then(resp => resp.text())
+ .catch(function(error) {
+ GM.log('Request failed', error);
+ return null;
+ });
+ };
}
Object.entries({
- 'log': console.log.bind(console), // Pale Moon compatibility. See #13.
- 'info': GM_info,
+ 'log': console.log.bind(console), // Pale Moon compatibility. See #13.
+ 'info': GM_info,
}).forEach(([newKey, old]) => {
- if (old && (typeof GM[newKey] == 'undefined')) {
- GM[newKey] = old;
- }
+ if (old && (typeof GM[newKey] == 'undefined')) {
+ GM[newKey] = old;
+ }
});
Object.entries({
- 'GM_addStyle': 'addStyle',
- 'GM_deleteValue': 'deleteValue',
- 'GM_getResourceURL': 'getResourceUrl',
- 'GM_getValue': 'getValue',
- 'GM_listValues': 'listValues',
- 'GM_notification': 'notification',
- 'GM_openInTab': 'openInTab',
- 'GM_registerMenuCommand': 'registerMenuCommand',
- 'GM_setClipboard': 'setClipboard',
- 'GM_setValue': 'setValue',
- 'GM_xmlhttpRequest': 'xmlHttpRequest',
- 'GM_getResourceText': 'getResourceText',
+ 'GM_addStyle': 'addStyle',
+ 'GM_deleteValue': 'deleteValue',
+ 'GM_getResourceURL': 'getResourceUrl',
+ 'GM_getValue': 'getValue',
+ 'GM_listValues': 'listValues',
+ 'GM_notification': 'notification',
+ 'GM_openInTab': 'openInTab',
+ 'GM_registerMenuCommand': 'registerMenuCommand',
+ 'GM_setClipboard': 'setClipboard',
+ 'GM_setValue': 'setValue',
+ 'GM_xmlhttpRequest': 'xmlHttpRequest',
+ 'GM_getResourceText': 'getResourceText',
}).forEach(([oldKey, newKey]) => {
- let old = this[oldKey];
- if (old && (typeof GM[newKey] == 'undefined')) {
- GM[newKey] = function(...args) {
- return new Promise((resolve, reject) => {
- try {
- resolve(old.apply(this, args));
- } catch (e) {
- reject(e);
- }
- });
- };
- }
+ let old = this[oldKey];
+ if (old && (typeof GM[newKey] == 'undefined')) {
+ GM[newKey] = function(...args) {
+ return new Promise((resolve, reject) => {
+ try {
+ resolve(old.apply(this, args));
+ } catch (e) {
+ reject(e);
+ }
+ });
+ };
+ }
});
diff --git a/scripts-greasemonkey/instagram_to_bibliogram.user.js b/scripts-greasemonkey/instagram_to_bibliogram.user.js
index ccf5b2f..f5aec45 100644
--- a/scripts-greasemonkey/instagram_to_bibliogram.user.js
+++ b/scripts-greasemonkey/instagram_to_bibliogram.user.js
@@ -8,7 +8,7 @@
// @exclude /^http(s|)://(www[.]|)bibliogram[.]art/.*$/
// @exclude /^http(s|)://(www[.]|)bibliogram[.]snopyta[.]org/.*$/
// @exclude /^http(s|)://(www[.]|)bibliogram[.]pussthecat[.]org/.*$/
-// @version 0.1.5
+// @version 0.1.6
// @grant none
// @license GPL version 3 or any later version::: https://www.gnu.org/licenses/gpl-3.0.html
// ==/UserScript==
@@ -18,24 +18,22 @@
let instance = 'bibliogram.snopyta.org';
// Console Style - Debug
-let consoleCSS = 'background: #000; color: #00FF00; padding: 0px 7px; border: 1px solid #00FF00; line-height: 16px;';
+const consoleCSS = 'background: #000; color: #00FF00; padding: 0px 7px; border: 1px solid #00FF00; line-height: 16px;';
+const name = GM_info.script.name;
+const version = GM_info.script.version;
+const log = (...args) => console.log('%cUSERSCRIPT | %s %s | %s', consoleCSS, name, version, ...args);
// Do the actual rewrite
function rewriteLinks() {
- for (let i = 0; i < document.links.length; i++) {
- let elem = document.links[i];
- if (elem.href.match(/http(s|):\/\/(mobile[.]|www[.]|)instagram[.]com\/(#!\/)?(.*$)/i)) {
- elem.href='https://' + instance + '/u/' + RegExp.$4;
- }
+ for (let i = 0; i < document.links.length; i++) {
+ let elem = document.links[i];
+ if (elem.href.match(/http(s|):\/\/(mobile[.]|www[.]|)instagram[.]com\/(#!\/)?(.*$)/i)) {
+ elem.href='https://' + instance + '/u/' + RegExp.$4;
}
- statuscheck()
-}
-
-function statuscheck(){
- // Console Feedback
- console.log("%cUSERSCRIPT | " + GM_info.script.name + " " + GM_info.script.version + " | successfully initialized", consoleCSS);
+ }
+ log('successfully initialized');
}
window.addEventListener('load', () => {
- rewriteLinks();
+ rewriteLinks();
});
diff --git a/scripts-greasemonkey/invidio_embed.user.js b/scripts-greasemonkey/invidio_embed.user.js
index 1a59d33..6c72b5f 100644
--- a/scripts-greasemonkey/invidio_embed.user.js
+++ b/scripts-greasemonkey/invidio_embed.user.js
@@ -17,14 +17,17 @@
// @exclude /^http(s|)://(www[.]|)invidious[.]enkirton[.]net/.*$/
// @exclude /^http(s|)://(www[.]|)tube[.]poal[.]co/.*$/
// @exclude /^http(s|)://(www[.]|)invidious[.]13ad[.]de/.*$/
-// @version 1.0.4
+// @version 1.0.5
// @grant none
// ==/UserScript==
let instance = 'invidio.us' // set instance
// Console Style - Debug
-let consoleCSS = 'background: #000; color: #00FF00; padding: 0px 7px; border: 1px solid #00FF00; line-height: 16px;';
+const consoleCSS = 'background: #000; color: #00FF00; padding: 0px 7px; border: 1px solid #00FF00; line-height: 16px;';
+const name = GM_info.script.name;
+const version = GM_info.script.version;
+const log = (...args) => console.log('%cUSERSCRIPT | %s %s | %s', consoleCSS, name, version, ...args);
let i, j, k, index;
let video_id, video_url, video_link;
@@ -36,59 +39,54 @@ let bad_elements = [];
let bad_ids = [];
for (i = 0; i < risky_tags.length; i++) {
- risky_elements = document.getElementsByTagName(risky_tags[i]);
- for (j = 0; j < risky_elements.length; j++) {
- index = 0;
- risky_attributes = risky_elements[j].attributes;
- for (k = 0; k < risky_attributes.length; k++) {
- risky_node = risky_attributes[k].value;
- if ((risky_node.indexOf("youtube.com") >= 0) || (risky_node.indexOf("ytimg.com") >= 0) || (risky_node.indexOf("youtube-nocookie.com") >= 0)) {
- risky_elements[j].style.display = "none";
- if (risky_node.indexOf("/v/") >= 0) {
- index = risky_node.indexOf("/v/") + 3;
- } else if (risky_node.indexOf("?v=") >= 0) {
- index = risky_node.indexOf("?v=") + 3;
- } else if (risky_node.indexOf("/embed/") >= 0) {
- index = risky_node.indexOf("/embed/") + 7;
- }
- if (index > 0) {
- video_id = risky_node.substring(index, index + 11);
- bad_elements.push(risky_elements[j]);
- bad_ids.push(video_id);
- }
- break;
- }
+ risky_elements = document.getElementsByTagName(risky_tags[i]);
+ for (j = 0; j < risky_elements.length; j++) {
+ index = 0;
+ risky_attributes = risky_elements[j].attributes;
+ for (k = 0; k < risky_attributes.length; k++) {
+ risky_node = risky_attributes[k].value;
+ if ((risky_node.indexOf("youtube.com") >= 0) || (risky_node.indexOf("ytimg.com") >= 0) || (risky_node.indexOf("youtube-nocookie.com") >= 0)) {
+ risky_elements[j].style.display = "none";
+ if (risky_node.indexOf("/v/") >= 0) {
+ index = risky_node.indexOf("/v/") + 3;
+ } else if (risky_node.indexOf("?v=") >= 0) {
+ index = risky_node.indexOf("?v=") + 3;
+ } else if (risky_node.indexOf("/embed/") >= 0) {
+ index = risky_node.indexOf("/embed/") + 7;
}
+ if (index > 0) {
+ video_id = risky_node.substring(index, index + 11);
+ bad_elements.push(risky_elements[j]);
+ bad_ids.push(video_id);
+ }
+ break;
+ }
}
+ }
}
for (i = 0; i < bad_ids.length; i++) {
- video_id = bad_ids[i];
- video_url = "//" + instance + "/embed/" + video_id;
- video_link = document.createElement("iframe");
- video_link.setAttribute("src", video_url);
+ video_id = bad_ids[i];
+ video_url = "//" + instance + "/embed/" + video_id;
+ video_link = document.createElement("iframe");
+ video_link.setAttribute("src", video_url);
- // Set the width, if present
- width = bad_elements[i].getAttribute("width");
- if ( width !== null ) {
- video_link.setAttribute("width", width);
- }
+ // Set the width, if present
+ width = bad_elements[i].getAttribute("width");
+ if ( width !== null ) {
+ video_link.setAttribute("width", width);
+ }
- // Set the height, if present
- height = bad_elements[i].getAttribute("height");
- if ( height !== null ) {
- video_link.setAttribute("height", height);
- }
+ // Set the height, if present
+ height = bad_elements[i].getAttribute("height");
+ if ( height !== null ) {
+ video_link.setAttribute("height", height);
+ }
- video_link.setAttribute("frameborder", "0");
- video_link.setAttribute("allowfullscreen", "1");
-
- bad_elements[i].parentNode.replaceChild(video_link, bad_elements[i]);
-}
+ video_link.setAttribute("frameborder", "0");
+ video_link.setAttribute("allowfullscreen", "1");
-function statuscheck(){
- // Console Feedback
- console.log("%cUSERSCRIPT | " + GM_info.script.name + " " + GM_info.script.version + " | successfully initialized", consoleCSS);
+ bad_elements[i].parentNode.replaceChild(video_link, bad_elements[i]);
}
-statuscheck()
+log('successfully initialized');
diff --git a/scripts-greasemonkey/invidio_proxy_mode.user.js b/scripts-greasemonkey/invidio_proxy_mode.user.js
index b9adf63..94fc3c5 100644
--- a/scripts-greasemonkey/invidio_proxy_mode.user.js
+++ b/scripts-greasemonkey/invidio_proxy_mode.user.js
@@ -1,6 +1,6 @@
// ==UserScript==
// @name Invidious - Proxy Mode
-// @version 0.1.8
+// @version 0.1.9
// @author Jesús E.
// @license GPL version 3 or any later version::: https://www.gnu.org/licenses/gpl-3.0.html
// @description This script automatically Proxy-Mode on Invidious and its various public instances.
@@ -21,33 +21,36 @@
// ==/UserScript==
function proxyMode() {
- const consoleCSS = 'background: #000; color: #00FF00; padding: 0px 7px; border: 1px solid #00FF00; line-height: 16px;';
+ const consoleCSS = 'background: #000; color: #00FF00; padding: 0px 7px; border: 1px solid #00FF00; line-height: 16px;';
+ const name = GM_info.script.name;
+ const version = GM_info.script.version;
+ const log = (...args) => console.log('%cUSERSCRIPT | %s %s | %s', consoleCSS, name, version, ...args);
- // Set variables
- let i, j, url;
- let vids_tags = ["video", "source"];
- let vids_elements, proxyURL;
+ // Set variables
+ let i, j, url;
+ let vids_tags = ["video", "source"];
+ let vids_elements, proxyURL;
- // Regex
- let params=new RegExp(/itag=(18|22|43)$/);
+ // Regex
+ let params=new RegExp(/itag=(18|22|43)$/);
- for (i = 0; i < vids_tags.length; i++) {
- vids_elements = document.getElementsByTagName(vids_tags[i]);
- for (j = 0; j < vids_elements.length; j++) {
- url = vids_elements.item(j).src;
- if(params.test(url)) {
- proxyURL = url + "&local=true";
- vids_elements.item(j).src = proxyURL;
- } else {
- console.log('Proxy was already applied or Live URL');
- }
- }
+ for (i = 0; i < vids_tags.length; i++) {
+ vids_elements = document.getElementsByTagName(vids_tags[i]);
+ for (j = 0; j < vids_elements.length; j++) {
+ url = vids_elements.item(j).src;
+ if(params.test(url)) {
+ proxyURL = url + "&local=true";
+ vids_elements.item(j).src = proxyURL;
+ } else {
+ console.log('Proxy was already applied or Live URL');
+ }
}
- console.log("%cUSERSCRIPT | " + GM_info.script.name + " " + GM_info.script.version + " | successfully initialized", consoleCSS);
+ }
+ log('successfully initialized');
}
proxyMode();
// Fix Abrowser
window.addEventListener('load', () => {
- proxyMode();
+ proxyMode();
});
diff --git a/scripts-greasemonkey/twitter_to_nitter.user.js b/scripts-greasemonkey/twitter_to_nitter.user.js
index e0e3e44..b712246 100644
--- a/scripts-greasemonkey/twitter_to_nitter.user.js
+++ b/scripts-greasemonkey/twitter_to_nitter.user.js
@@ -13,7 +13,7 @@
// @exclude /^http(s|)://(www[.]|)nitter[.]nixnet[.]xyz/.*$/
// @exclude /^http(s|)://(www[.]|)nitter[.]drycat[.]fr/.*$/
// @exclude /^http(s|)://(www[.]|)tw[.]openalgeria[.]org/.*$/
-// @version 0.1.3
+// @version 0.1.4
// @grant none
// @license GPL version 3 or any later version::: https://www.gnu.org/licenses/gpl-3.0.html
// ==/UserScript==
@@ -23,24 +23,22 @@
let instance = 'nitter.net';
// Console Style - Debug
-let consoleCSS = 'background: #000; color: #00FF00; padding: 0px 7px; border: 1px solid #00FF00; line-height: 16px;';
+const consoleCSS = 'background: #000; color: #00FF00; padding: 0px 7px; border: 1px solid #00FF00; line-height: 16px;';
+const name = GM_info.script.name;
+const version = GM_info.script.version;
+const log = (...args) => console.log('%cUSERSCRIPT | %s %s | %s', consoleCSS, name, version, ...args);
// Do the actual rewrite
function rewriteLinks() {
- for (let i = 0; i < document.links.length; i++) {
- let elem = document.links[i];
- if (elem.href.match(/http(s|):\/\/(mobile[.]|www[.]|)twitter[.]com\/(#!\/)?(.*$)/i)) {
- elem.href='https://' + instance + '/' + RegExp.$4;
- }
+ for (let i = 0; i < document.links.length; i++) {
+ let elem = document.links[i];
+ if (elem.href.match(/http(s|):\/\/(mobile[.]|www[.]|)twitter[.]com\/(#!\/)?(.*$)/i)) {
+ elem.href='https://' + instance + '/' + RegExp.$4;
}
- statuscheck()
-}
-
-function statuscheck(){
- // Console Feedback
- console.log("%cUSERSCRIPT | " + GM_info.script.name + " " + GM_info.script.version + " | successfully initialized", consoleCSS);
+ }
+ log('successfully initialized');
}
window.addEventListener('load', () => {
- rewriteLinks();
+ rewriteLinks();
});
diff --git a/scripts-greasemonkey/youtube_to_invidious.user.js b/scripts-greasemonkey/youtube_to_invidious.user.js
index 4ff0463..52a86b5 100644
--- a/scripts-greasemonkey/youtube_to_invidious.user.js
+++ b/scripts-greasemonkey/youtube_to_invidious.user.js
@@ -16,7 +16,7 @@
// @exclude /^http(s|)://(www[.]|)tube[.]poal[.]co/.*$/
// @exclude /^http(s|)://(www[.]|)invidious[.]13ad[.]de/.*$/
// @grant none
-// @version 8.4.8
+// @version 8.4.9
// @license GPL version 3 or any later version::: https://www.gnu.org/licenses/gpl-3.0.html
// ==/UserScript==
/* jshint esversion: 6 */
@@ -25,7 +25,10 @@
let instance = 'invidio.us';
// Console Style - Debug
-let consoleCSS = 'background: #000; color: #00FF00; padding: 0px 7px; border: 1px solid #00FF00; line-height: 16px;';
+const consoleCSS = 'background: #000; color: #00FF00; padding: 0px 7px; border: 1px solid #00FF00; line-height: 16px;';
+const name = GM_info.script.name;
+const version = GM_info.script.version;
+const log = (...args) => console.log('%cUSERSCRIPT | %s %s | %s', consoleCSS, name, version, ...args);
// change script options, default values recommended
let a=1; //set to 0 to force autoplay off, set to 1 to keep embed's value [default 1]
@@ -36,98 +39,93 @@ let params=new RegExp(/^(autoplay|channel|v|playlist|list)$/);
let current=window.location.href.match(ytdomains)===null;
let thumbs,links,skip;
-function statuscheck(){
- // Console Feedback
- console.log("%cUSERSCRIPT | " + GM_info.script.name + " " + GM_info.script.version + " | successfully initialized", consoleCSS);
-}
-
function link(){
- for(let i=0;i<links.length;i++){
- let url=new URL(links[i].href.match(ytdomains)[0]);
- url.hostname=instance;
- links[i].href=url;
- }
+ for(let i=0;i<links.length;i++){
+ let url=new URL(links[i].href.match(ytdomains)[0]);
+ url.hostname=instance;
+ links[i].href=url;
+ }
}
function ytel(el){
- for(let i=0;i<el.attributes.length;i++){
- let val=el.attributes[i].value;
- if(val.substring(0,2)=='//')val='https:'+val;
- try{val=decodeURIComponent(val);}catch(e){}
- if(val.match(ytdomains)){
- el.attributes[i].value=val;
- return true;
- }
+ for(let i=0;i<el.attributes.length;i++){
+ let val=el.attributes[i].value;
+ if(val.substring(0,2)=='//')val='https:'+val;
+ try{val=decodeURIComponent(val);}catch(e){}
+ if(val.match(ytdomains)){
+ el.attributes[i].value=val;
+ return true;
}
+ }
}
function ythref(el){
- return(decodeURIComponent(el.href).match(ytdomains));
+ return(decodeURIComponent(el.href).match(ytdomains));
}
function thumb(){
- for(let i=0;i<thumbs.length;i++){
- let url=new URL(thumbs[i].src.match(ytdomains)[0]);
- url.hostname=instance;
- thumbs[i].src=url;
- }
+ for(let i=0;i<thumbs.length;i++){
+ let url=new URL(thumbs[i].src.match(ytdomains)[0]);
+ url.hostname=instance;
+ thumbs[i].src=url;
+ }
}
function redir(){
- let url=new URL(window.location.href);
- url.hostname=instance;
- location.href=url;
+ let url=new URL(window.location.href);
+ url.hostname=instance;
+ location.href=url;
}
function addbtn(){
- for(let i=0;i<title.length;i++){
- let btn=document.createElement('a');
- btn.innerHTML='<h2>Watch on '+instance+'</h2>';
- btn.href='javascript:void(0)';
- btn.onclick=function(){
- redir();
- }
- btn.className='skipinv';
- title[i].parentNode.appendChild(btn);
+ for(let i=0;i<title.length;i++){
+ let btn=document.createElement('a');
+ btn.innerHTML='<h2>Watch on '+instance+'</h2>';
+ btn.href='javascript:void(0)';
+ btn.onclick=function(){
+ redir();
}
+ btn.className='skipinv';
+ title[i].parentNode.appendChild(btn);
+ }
}
if(current){
- thumbs=Array.prototype.slice.call(document.getElementsByTagName('img')).filter(ytel);
- if(b==1)links=Array.prototype.slice.call(document.getElementsByTagName('a')).filter(ythref);
- if(thumbs.length>0){
- thumb();
- }
- if(links.length>0){
- link();
- }
- statuscheck();
+ thumbs=Array.prototype.slice.call(document.getElementsByTagName('img')).filter(ytel);
+ if(b==1)links=Array.prototype.slice.call(document.getElementsByTagName('a')).filter(ythref);
+ if(thumbs.length>0){
+ thumb();
+ }
+ if(links.length>0){
+ link();
+ }
+ log('successfully initialized');
}else{
- let title=Array.prototype.slice.call(document.getElementsByTagName('h1'));
- addbtn();
+ let title=Array.prototype.slice.call(document.getElementsByTagName('h1'));
+ addbtn();
}
let observer=new MutationObserver(function(mutations){
- mutations.forEach(function(mutation){
- if(current){
- thumbs=Array.prototype.slice.call(mutation.target.getElementsByTagName('img')).filter(ytel);
- if(thumbs.length>0){
- thumb();
- }
- if(b==1){
- links=Array.prototype.slice.call(mutation.target.getElementsByTagName('a')).filter(ythref);
- if(links.length>0){
- link();
- }
- }
- }else{
- skip=Array.prototype.slice.call(mutation.target.getElementsByClassName('skipinv'));
- if(skip<1){
- title=Array.prototype.slice.call(mutation.target.getElementsByTagName('h1'));
- addbtn();
- }
+ mutations.forEach(function(mutation){
+ if(current){
+ thumbs=Array.prototype.slice.call(mutation.target.getElementsByTagName('img')).filter(ytel);
+ if(thumbs.length>0){
+ thumb();
+ }
+ if(b==1){
+ links=Array.prototype.slice.call(mutation.target.getElementsByTagName('a')).filter(ythref);
+ if(links.length>0){
+ link();
}
- });
+ }
+ }else{
+ skip=Array.prototype.slice.call(mutation.target.getElementsByClassName('skipinv'));
+ if(skip<1){
+ title=Array.prototype.slice.call(mutation.target.getElementsByTagName('h1'));
+ addbtn();
+ }
+ }
+ });
});
observer.observe(document.body,{childList:true,subtree:true});