scripts-greasemonkey: Improve log message
* fix change indent-spaces: 4 to 2
This commit is contained in:
parent
f2c9969b12
commit
cca78b770c
@ -6,7 +6,7 @@
|
|||||||
// @homepageURL https://libregit.spks.xyz/heckyel/book/src/branch/master/scripts-greasemonkey
|
// @homepageURL https://libregit.spks.xyz/heckyel/book/src/branch/master/scripts-greasemonkey
|
||||||
// @include *
|
// @include *
|
||||||
// @grant none
|
// @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
|
// @license GPL version 3 or any later version::: https://www.gnu.org/licenses/gpl-3.0.html
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
/* jshint esversion: 6 */
|
/* jshint esversion: 6 */
|
||||||
|
@ -25,106 +25,106 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (typeof GM == 'undefined') {
|
if (typeof GM == 'undefined') {
|
||||||
this.GM = {};
|
this.GM = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (typeof GM_addStyle == 'undefined') {
|
if (typeof GM_addStyle == 'undefined') {
|
||||||
this.GM_addStyle = (aCss) => {
|
this.GM_addStyle = (aCss) => {
|
||||||
'use strict';
|
'use strict';
|
||||||
let head = document.getElementsByTagName('head')[0];
|
let head = document.getElementsByTagName('head')[0];
|
||||||
if (head) {
|
if (head) {
|
||||||
let style = document.createElement('style');
|
let style = document.createElement('style');
|
||||||
style.setAttribute('type', 'text/css');
|
style.setAttribute('type', 'text/css');
|
||||||
style.textContent = aCss;
|
style.textContent = aCss;
|
||||||
head.appendChild(style);
|
head.appendChild(style);
|
||||||
return style;
|
return style;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (typeof GM_registerMenuCommand == 'undefined') {
|
if (typeof GM_registerMenuCommand == 'undefined') {
|
||||||
this.GM_registerMenuCommand = (caption, commandFunc, accessKey) => {
|
this.GM_registerMenuCommand = (caption, commandFunc, accessKey) => {
|
||||||
if (!document.body) {
|
if (!document.body) {
|
||||||
if (document.readyState === 'loading'
|
if (document.readyState === 'loading'
|
||||||
&& document.documentElement && document.documentElement.localName === 'html') {
|
&& document.documentElement && document.documentElement.localName === 'html') {
|
||||||
new MutationObserver((mutations, observer) => {
|
new MutationObserver((mutations, observer) => {
|
||||||
if (document.body) {
|
if (document.body) {
|
||||||
observer.disconnect();
|
observer.disconnect();
|
||||||
GM_registerMenuCommand(caption, commandFunc, accessKey);
|
GM_registerMenuCommand(caption, commandFunc, accessKey);
|
||||||
}
|
}
|
||||||
}).observe(document.documentElement, {childList: true});
|
}).observe(document.documentElement, {childList: true});
|
||||||
} else {
|
} else {
|
||||||
console.error('GM_registerMenuCommand got no body.');
|
console.error('GM_registerMenuCommand got no body.');
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let contextMenu = document.body.getAttribute('contextmenu');
|
let contextMenu = document.body.getAttribute('contextmenu');
|
||||||
let menu = (contextMenu ? document.querySelector('menu#' + contextMenu) : null);
|
let menu = (contextMenu ? document.querySelector('menu#' + contextMenu) : null);
|
||||||
if (!menu) {
|
if (!menu) {
|
||||||
menu = document.createElement('menu');
|
menu = document.createElement('menu');
|
||||||
menu.setAttribute('id', 'gm-registered-menu');
|
menu.setAttribute('id', 'gm-registered-menu');
|
||||||
menu.setAttribute('type', 'context');
|
menu.setAttribute('type', 'context');
|
||||||
document.body.appendChild(menu);
|
document.body.appendChild(menu);
|
||||||
document.body.setAttribute('contextmenu', 'gm-registered-menu');
|
document.body.setAttribute('contextmenu', 'gm-registered-menu');
|
||||||
}
|
}
|
||||||
let menuItem = document.createElement('menuitem');
|
let menuItem = document.createElement('menuitem');
|
||||||
menuItem.textContent = caption;
|
menuItem.textContent = caption;
|
||||||
menuItem.addEventListener('click', commandFunc, true);
|
menuItem.addEventListener('click', commandFunc, true);
|
||||||
menu.appendChild(menuItem);
|
menu.appendChild(menuItem);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (typeof GM_getResourceText == 'undefined') {
|
if (typeof GM_getResourceText == 'undefined') {
|
||||||
this.GM_getResourceText = (aRes) => {
|
this.GM_getResourceText = (aRes) => {
|
||||||
'use strict';
|
'use strict';
|
||||||
return GM.getResourceUrl(aRes)
|
return GM.getResourceUrl(aRes)
|
||||||
.then(url => fetch(url))
|
.then(url => fetch(url))
|
||||||
.then(resp => resp.text())
|
.then(resp => resp.text())
|
||||||
.catch(function(error) {
|
.catch(function(error) {
|
||||||
GM.log('Request failed', error);
|
GM.log('Request failed', error);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Object.entries({
|
Object.entries({
|
||||||
'log': console.log.bind(console), // Pale Moon compatibility. See #13.
|
'log': console.log.bind(console), // Pale Moon compatibility. See #13.
|
||||||
'info': GM_info,
|
'info': GM_info,
|
||||||
}).forEach(([newKey, old]) => {
|
}).forEach(([newKey, old]) => {
|
||||||
if (old && (typeof GM[newKey] == 'undefined')) {
|
if (old && (typeof GM[newKey] == 'undefined')) {
|
||||||
GM[newKey] = old;
|
GM[newKey] = old;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Object.entries({
|
Object.entries({
|
||||||
'GM_addStyle': 'addStyle',
|
'GM_addStyle': 'addStyle',
|
||||||
'GM_deleteValue': 'deleteValue',
|
'GM_deleteValue': 'deleteValue',
|
||||||
'GM_getResourceURL': 'getResourceUrl',
|
'GM_getResourceURL': 'getResourceUrl',
|
||||||
'GM_getValue': 'getValue',
|
'GM_getValue': 'getValue',
|
||||||
'GM_listValues': 'listValues',
|
'GM_listValues': 'listValues',
|
||||||
'GM_notification': 'notification',
|
'GM_notification': 'notification',
|
||||||
'GM_openInTab': 'openInTab',
|
'GM_openInTab': 'openInTab',
|
||||||
'GM_registerMenuCommand': 'registerMenuCommand',
|
'GM_registerMenuCommand': 'registerMenuCommand',
|
||||||
'GM_setClipboard': 'setClipboard',
|
'GM_setClipboard': 'setClipboard',
|
||||||
'GM_setValue': 'setValue',
|
'GM_setValue': 'setValue',
|
||||||
'GM_xmlhttpRequest': 'xmlHttpRequest',
|
'GM_xmlhttpRequest': 'xmlHttpRequest',
|
||||||
'GM_getResourceText': 'getResourceText',
|
'GM_getResourceText': 'getResourceText',
|
||||||
}).forEach(([oldKey, newKey]) => {
|
}).forEach(([oldKey, newKey]) => {
|
||||||
let old = this[oldKey];
|
let old = this[oldKey];
|
||||||
if (old && (typeof GM[newKey] == 'undefined')) {
|
if (old && (typeof GM[newKey] == 'undefined')) {
|
||||||
GM[newKey] = function(...args) {
|
GM[newKey] = function(...args) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
resolve(old.apply(this, args));
|
resolve(old.apply(this, args));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
reject(e);
|
reject(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
// @exclude /^http(s|)://(www[.]|)bibliogram[.]art/.*$/
|
// @exclude /^http(s|)://(www[.]|)bibliogram[.]art/.*$/
|
||||||
// @exclude /^http(s|)://(www[.]|)bibliogram[.]snopyta[.]org/.*$/
|
// @exclude /^http(s|)://(www[.]|)bibliogram[.]snopyta[.]org/.*$/
|
||||||
// @exclude /^http(s|)://(www[.]|)bibliogram[.]pussthecat[.]org/.*$/
|
// @exclude /^http(s|)://(www[.]|)bibliogram[.]pussthecat[.]org/.*$/
|
||||||
// @version 0.1.5
|
// @version 0.1.6
|
||||||
// @grant none
|
// @grant none
|
||||||
// @license GPL version 3 or any later version::: https://www.gnu.org/licenses/gpl-3.0.html
|
// @license GPL version 3 or any later version::: https://www.gnu.org/licenses/gpl-3.0.html
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
@ -18,24 +18,22 @@
|
|||||||
let instance = 'bibliogram.snopyta.org';
|
let instance = 'bibliogram.snopyta.org';
|
||||||
|
|
||||||
// Console Style - Debug
|
// 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
|
// Do the actual rewrite
|
||||||
function rewriteLinks() {
|
function rewriteLinks() {
|
||||||
for (let i = 0; i < document.links.length; i++) {
|
for (let i = 0; i < document.links.length; i++) {
|
||||||
let elem = document.links[i];
|
let elem = document.links[i];
|
||||||
if (elem.href.match(/http(s|):\/\/(mobile[.]|www[.]|)instagram[.]com\/(#!\/)?(.*$)/i)) {
|
if (elem.href.match(/http(s|):\/\/(mobile[.]|www[.]|)instagram[.]com\/(#!\/)?(.*$)/i)) {
|
||||||
elem.href='https://' + instance + '/u/' + RegExp.$4;
|
elem.href='https://' + instance + '/u/' + RegExp.$4;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
statuscheck()
|
}
|
||||||
}
|
log('successfully initialized');
|
||||||
|
|
||||||
function statuscheck(){
|
|
||||||
// Console Feedback
|
|
||||||
console.log("%cUSERSCRIPT | " + GM_info.script.name + " " + GM_info.script.version + " | successfully initialized", consoleCSS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('load', () => {
|
window.addEventListener('load', () => {
|
||||||
rewriteLinks();
|
rewriteLinks();
|
||||||
});
|
});
|
||||||
|
@ -17,14 +17,17 @@
|
|||||||
// @exclude /^http(s|)://(www[.]|)invidious[.]enkirton[.]net/.*$/
|
// @exclude /^http(s|)://(www[.]|)invidious[.]enkirton[.]net/.*$/
|
||||||
// @exclude /^http(s|)://(www[.]|)tube[.]poal[.]co/.*$/
|
// @exclude /^http(s|)://(www[.]|)tube[.]poal[.]co/.*$/
|
||||||
// @exclude /^http(s|)://(www[.]|)invidious[.]13ad[.]de/.*$/
|
// @exclude /^http(s|)://(www[.]|)invidious[.]13ad[.]de/.*$/
|
||||||
// @version 1.0.4
|
// @version 1.0.5
|
||||||
// @grant none
|
// @grant none
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
let instance = 'invidio.us' // set instance
|
let instance = 'invidio.us' // set instance
|
||||||
|
|
||||||
// Console Style - Debug
|
// 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 i, j, k, index;
|
||||||
let video_id, video_url, video_link;
|
let video_id, video_url, video_link;
|
||||||
@ -36,59 +39,54 @@ let bad_elements = [];
|
|||||||
let bad_ids = [];
|
let bad_ids = [];
|
||||||
|
|
||||||
for (i = 0; i < risky_tags.length; i++) {
|
for (i = 0; i < risky_tags.length; i++) {
|
||||||
risky_elements = document.getElementsByTagName(risky_tags[i]);
|
risky_elements = document.getElementsByTagName(risky_tags[i]);
|
||||||
for (j = 0; j < risky_elements.length; j++) {
|
for (j = 0; j < risky_elements.length; j++) {
|
||||||
index = 0;
|
index = 0;
|
||||||
risky_attributes = risky_elements[j].attributes;
|
risky_attributes = risky_elements[j].attributes;
|
||||||
for (k = 0; k < risky_attributes.length; k++) {
|
for (k = 0; k < risky_attributes.length; k++) {
|
||||||
risky_node = risky_attributes[k].value;
|
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)) {
|
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";
|
risky_elements[j].style.display = "none";
|
||||||
if (risky_node.indexOf("/v/") >= 0) {
|
if (risky_node.indexOf("/v/") >= 0) {
|
||||||
index = risky_node.indexOf("/v/") + 3;
|
index = risky_node.indexOf("/v/") + 3;
|
||||||
} else if (risky_node.indexOf("?v=") >= 0) {
|
} else if (risky_node.indexOf("?v=") >= 0) {
|
||||||
index = risky_node.indexOf("?v=") + 3;
|
index = risky_node.indexOf("?v=") + 3;
|
||||||
} else if (risky_node.indexOf("/embed/") >= 0) {
|
} else if (risky_node.indexOf("/embed/") >= 0) {
|
||||||
index = risky_node.indexOf("/embed/") + 7;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
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++) {
|
for (i = 0; i < bad_ids.length; i++) {
|
||||||
video_id = bad_ids[i];
|
video_id = bad_ids[i];
|
||||||
video_url = "//" + instance + "/embed/" + video_id;
|
video_url = "//" + instance + "/embed/" + video_id;
|
||||||
video_link = document.createElement("iframe");
|
video_link = document.createElement("iframe");
|
||||||
video_link.setAttribute("src", video_url);
|
video_link.setAttribute("src", video_url);
|
||||||
|
|
||||||
// Set the width, if present
|
// Set the width, if present
|
||||||
width = bad_elements[i].getAttribute("width");
|
width = bad_elements[i].getAttribute("width");
|
||||||
if ( width !== null ) {
|
if ( width !== null ) {
|
||||||
video_link.setAttribute("width", width);
|
video_link.setAttribute("width", width);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the height, if present
|
// Set the height, if present
|
||||||
height = bad_elements[i].getAttribute("height");
|
height = bad_elements[i].getAttribute("height");
|
||||||
if ( height !== null ) {
|
if ( height !== null ) {
|
||||||
video_link.setAttribute("height", height);
|
video_link.setAttribute("height", height);
|
||||||
}
|
}
|
||||||
|
|
||||||
video_link.setAttribute("frameborder", "0");
|
video_link.setAttribute("frameborder", "0");
|
||||||
video_link.setAttribute("allowfullscreen", "1");
|
video_link.setAttribute("allowfullscreen", "1");
|
||||||
|
|
||||||
bad_elements[i].parentNode.replaceChild(video_link, bad_elements[i]);
|
bad_elements[i].parentNode.replaceChild(video_link, bad_elements[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function statuscheck(){
|
log('successfully initialized');
|
||||||
// Console Feedback
|
|
||||||
console.log("%cUSERSCRIPT | " + GM_info.script.name + " " + GM_info.script.version + " | successfully initialized", consoleCSS);
|
|
||||||
}
|
|
||||||
|
|
||||||
statuscheck()
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Invidious - Proxy Mode
|
// @name Invidious - Proxy Mode
|
||||||
// @version 0.1.8
|
// @version 0.1.9
|
||||||
// @author Jesús E.
|
// @author Jesús E.
|
||||||
// @license GPL version 3 or any later version::: https://www.gnu.org/licenses/gpl-3.0.html
|
// @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.
|
// @description This script automatically Proxy-Mode on Invidious and its various public instances.
|
||||||
@ -21,33 +21,36 @@
|
|||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
function proxyMode() {
|
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
|
// Set variables
|
||||||
let i, j, url;
|
let i, j, url;
|
||||||
let vids_tags = ["video", "source"];
|
let vids_tags = ["video", "source"];
|
||||||
let vids_elements, proxyURL;
|
let vids_elements, proxyURL;
|
||||||
|
|
||||||
// Regex
|
// Regex
|
||||||
let params=new RegExp(/itag=(18|22|43)$/);
|
let params=new RegExp(/itag=(18|22|43)$/);
|
||||||
|
|
||||||
for (i = 0; i < vids_tags.length; i++) {
|
for (i = 0; i < vids_tags.length; i++) {
|
||||||
vids_elements = document.getElementsByTagName(vids_tags[i]);
|
vids_elements = document.getElementsByTagName(vids_tags[i]);
|
||||||
for (j = 0; j < vids_elements.length; j++) {
|
for (j = 0; j < vids_elements.length; j++) {
|
||||||
url = vids_elements.item(j).src;
|
url = vids_elements.item(j).src;
|
||||||
if(params.test(url)) {
|
if(params.test(url)) {
|
||||||
proxyURL = url + "&local=true";
|
proxyURL = url + "&local=true";
|
||||||
vids_elements.item(j).src = proxyURL;
|
vids_elements.item(j).src = proxyURL;
|
||||||
} else {
|
} else {
|
||||||
console.log('Proxy was already applied or Live URL');
|
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();
|
proxyMode();
|
||||||
|
|
||||||
// Fix Abrowser
|
// Fix Abrowser
|
||||||
window.addEventListener('load', () => {
|
window.addEventListener('load', () => {
|
||||||
proxyMode();
|
proxyMode();
|
||||||
});
|
});
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
// @exclude /^http(s|)://(www[.]|)nitter[.]nixnet[.]xyz/.*$/
|
// @exclude /^http(s|)://(www[.]|)nitter[.]nixnet[.]xyz/.*$/
|
||||||
// @exclude /^http(s|)://(www[.]|)nitter[.]drycat[.]fr/.*$/
|
// @exclude /^http(s|)://(www[.]|)nitter[.]drycat[.]fr/.*$/
|
||||||
// @exclude /^http(s|)://(www[.]|)tw[.]openalgeria[.]org/.*$/
|
// @exclude /^http(s|)://(www[.]|)tw[.]openalgeria[.]org/.*$/
|
||||||
// @version 0.1.3
|
// @version 0.1.4
|
||||||
// @grant none
|
// @grant none
|
||||||
// @license GPL version 3 or any later version::: https://www.gnu.org/licenses/gpl-3.0.html
|
// @license GPL version 3 or any later version::: https://www.gnu.org/licenses/gpl-3.0.html
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
@ -23,24 +23,22 @@
|
|||||||
let instance = 'nitter.net';
|
let instance = 'nitter.net';
|
||||||
|
|
||||||
// Console Style - Debug
|
// 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
|
// Do the actual rewrite
|
||||||
function rewriteLinks() {
|
function rewriteLinks() {
|
||||||
for (let i = 0; i < document.links.length; i++) {
|
for (let i = 0; i < document.links.length; i++) {
|
||||||
let elem = document.links[i];
|
let elem = document.links[i];
|
||||||
if (elem.href.match(/http(s|):\/\/(mobile[.]|www[.]|)twitter[.]com\/(#!\/)?(.*$)/i)) {
|
if (elem.href.match(/http(s|):\/\/(mobile[.]|www[.]|)twitter[.]com\/(#!\/)?(.*$)/i)) {
|
||||||
elem.href='https://' + instance + '/' + RegExp.$4;
|
elem.href='https://' + instance + '/' + RegExp.$4;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
statuscheck()
|
}
|
||||||
}
|
log('successfully initialized');
|
||||||
|
|
||||||
function statuscheck(){
|
|
||||||
// Console Feedback
|
|
||||||
console.log("%cUSERSCRIPT | " + GM_info.script.name + " " + GM_info.script.version + " | successfully initialized", consoleCSS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('load', () => {
|
window.addEventListener('load', () => {
|
||||||
rewriteLinks();
|
rewriteLinks();
|
||||||
});
|
});
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
// @exclude /^http(s|)://(www[.]|)tube[.]poal[.]co/.*$/
|
// @exclude /^http(s|)://(www[.]|)tube[.]poal[.]co/.*$/
|
||||||
// @exclude /^http(s|)://(www[.]|)invidious[.]13ad[.]de/.*$/
|
// @exclude /^http(s|)://(www[.]|)invidious[.]13ad[.]de/.*$/
|
||||||
// @grant none
|
// @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
|
// @license GPL version 3 or any later version::: https://www.gnu.org/licenses/gpl-3.0.html
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
/* jshint esversion: 6 */
|
/* jshint esversion: 6 */
|
||||||
@ -25,7 +25,10 @@
|
|||||||
let instance = 'invidio.us';
|
let instance = 'invidio.us';
|
||||||
|
|
||||||
// Console Style - Debug
|
// 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
|
// 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]
|
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 current=window.location.href.match(ytdomains)===null;
|
||||||
let thumbs,links,skip;
|
let thumbs,links,skip;
|
||||||
|
|
||||||
function statuscheck(){
|
|
||||||
// Console Feedback
|
|
||||||
console.log("%cUSERSCRIPT | " + GM_info.script.name + " " + GM_info.script.version + " | successfully initialized", consoleCSS);
|
|
||||||
}
|
|
||||||
|
|
||||||
function link(){
|
function link(){
|
||||||
for(let i=0;i<links.length;i++){
|
for(let i=0;i<links.length;i++){
|
||||||
let url=new URL(links[i].href.match(ytdomains)[0]);
|
let url=new URL(links[i].href.match(ytdomains)[0]);
|
||||||
url.hostname=instance;
|
url.hostname=instance;
|
||||||
links[i].href=url;
|
links[i].href=url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ytel(el){
|
function ytel(el){
|
||||||
for(let i=0;i<el.attributes.length;i++){
|
for(let i=0;i<el.attributes.length;i++){
|
||||||
let val=el.attributes[i].value;
|
let val=el.attributes[i].value;
|
||||||
if(val.substring(0,2)=='//')val='https:'+val;
|
if(val.substring(0,2)=='//')val='https:'+val;
|
||||||
try{val=decodeURIComponent(val);}catch(e){}
|
try{val=decodeURIComponent(val);}catch(e){}
|
||||||
if(val.match(ytdomains)){
|
if(val.match(ytdomains)){
|
||||||
el.attributes[i].value=val;
|
el.attributes[i].value=val;
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ythref(el){
|
function ythref(el){
|
||||||
return(decodeURIComponent(el.href).match(ytdomains));
|
return(decodeURIComponent(el.href).match(ytdomains));
|
||||||
}
|
}
|
||||||
|
|
||||||
function thumb(){
|
function thumb(){
|
||||||
for(let i=0;i<thumbs.length;i++){
|
for(let i=0;i<thumbs.length;i++){
|
||||||
let url=new URL(thumbs[i].src.match(ytdomains)[0]);
|
let url=new URL(thumbs[i].src.match(ytdomains)[0]);
|
||||||
url.hostname=instance;
|
url.hostname=instance;
|
||||||
thumbs[i].src=url;
|
thumbs[i].src=url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function redir(){
|
function redir(){
|
||||||
let url=new URL(window.location.href);
|
let url=new URL(window.location.href);
|
||||||
url.hostname=instance;
|
url.hostname=instance;
|
||||||
location.href=url;
|
location.href=url;
|
||||||
}
|
}
|
||||||
|
|
||||||
function addbtn(){
|
function addbtn(){
|
||||||
for(let i=0;i<title.length;i++){
|
for(let i=0;i<title.length;i++){
|
||||||
let btn=document.createElement('a');
|
let btn=document.createElement('a');
|
||||||
btn.innerHTML='<h2>Watch on '+instance+'</h2>';
|
btn.innerHTML='<h2>Watch on '+instance+'</h2>';
|
||||||
btn.href='javascript:void(0)';
|
btn.href='javascript:void(0)';
|
||||||
btn.onclick=function(){
|
btn.onclick=function(){
|
||||||
redir();
|
redir();
|
||||||
}
|
|
||||||
btn.className='skipinv';
|
|
||||||
title[i].parentNode.appendChild(btn);
|
|
||||||
}
|
}
|
||||||
|
btn.className='skipinv';
|
||||||
|
title[i].parentNode.appendChild(btn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(current){
|
if(current){
|
||||||
thumbs=Array.prototype.slice.call(document.getElementsByTagName('img')).filter(ytel);
|
thumbs=Array.prototype.slice.call(document.getElementsByTagName('img')).filter(ytel);
|
||||||
if(b==1)links=Array.prototype.slice.call(document.getElementsByTagName('a')).filter(ythref);
|
if(b==1)links=Array.prototype.slice.call(document.getElementsByTagName('a')).filter(ythref);
|
||||||
if(thumbs.length>0){
|
if(thumbs.length>0){
|
||||||
thumb();
|
thumb();
|
||||||
}
|
}
|
||||||
if(links.length>0){
|
if(links.length>0){
|
||||||
link();
|
link();
|
||||||
}
|
}
|
||||||
statuscheck();
|
log('successfully initialized');
|
||||||
}else{
|
}else{
|
||||||
let title=Array.prototype.slice.call(document.getElementsByTagName('h1'));
|
let title=Array.prototype.slice.call(document.getElementsByTagName('h1'));
|
||||||
addbtn();
|
addbtn();
|
||||||
}
|
}
|
||||||
|
|
||||||
let observer=new MutationObserver(function(mutations){
|
let observer=new MutationObserver(function(mutations){
|
||||||
mutations.forEach(function(mutation){
|
mutations.forEach(function(mutation){
|
||||||
if(current){
|
if(current){
|
||||||
thumbs=Array.prototype.slice.call(mutation.target.getElementsByTagName('img')).filter(ytel);
|
thumbs=Array.prototype.slice.call(mutation.target.getElementsByTagName('img')).filter(ytel);
|
||||||
if(thumbs.length>0){
|
if(thumbs.length>0){
|
||||||
thumb();
|
thumb();
|
||||||
}
|
}
|
||||||
if(b==1){
|
if(b==1){
|
||||||
links=Array.prototype.slice.call(mutation.target.getElementsByTagName('a')).filter(ythref);
|
links=Array.prototype.slice.call(mutation.target.getElementsByTagName('a')).filter(ythref);
|
||||||
if(links.length>0){
|
if(links.length>0){
|
||||||
link();
|
link();
|
||||||
}
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
skip=Array.prototype.slice.call(mutation.target.getElementsByClassName('skipinv'));
|
|
||||||
if(skip<1){
|
|
||||||
title=Array.prototype.slice.call(mutation.target.getElementsByTagName('h1'));
|
|
||||||
addbtn();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
}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});
|
observer.observe(document.body,{childList:true,subtree:true});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user