47 lines
1.8 KiB
JavaScript
47 lines
1.8 KiB
JavaScript
// ==UserScript==
|
|
// @name Twitter to Nitter
|
|
// @author Jesús E.
|
|
// @namespace NitterRedirect
|
|
// @description Scan page for Twitter and urls replace with Nitter
|
|
// @homepageURL https://libregit.org/heckyel/book/src/branch/master/scripts-greasemonkey
|
|
// @include *
|
|
// @exclude /^http(s|)://(www[.]|)nitter[.]net/.*$/
|
|
// @exclude /^http(s|)://(www[.]|)nitter[.]pro/.*$/
|
|
// @exclude /^http(s|)://(www[.]|)nitter[.]snopyta[.]org/.*$/
|
|
// @exclude /^http(s|)://(www[.]|)nitter[.]42l[.]fr/.*$/
|
|
// @exclude /^http(s|)://(www[.]|)nitter[.]13ad[.]de/.*$/
|
|
// @exclude /^http(s|)://(www[.]|)nitter[.]nixnet[.]xyz/.*$/
|
|
// @exclude /^http(s|)://(www[.]|)nitter[.]drycat[.]fr/.*$/
|
|
// @exclude /^http(s|)://(www[.]|)tw[.]openalgeria[.]org/.*$/
|
|
// @version 0.1
|
|
// @grant none
|
|
// @license GPL version 3 or any later version::: https://www.gnu.org/licenses/gpl-3.0.html
|
|
// ==/UserScript==
|
|
/* jshint esversion: 6 */
|
|
|
|
// Set you favorite Nitter instance! (https://github.com/zedeus/nitter/wiki/Instances)
|
|
let instance = 'nitter.net';
|
|
|
|
// Console Style - Debug
|
|
let consoleCSS = 'background: #000; color: #00FF00; padding: 0px 7px; border: 1px solid #00FF00; line-height: 16px;';
|
|
|
|
// 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;
|
|
}
|
|
}
|
|
statuscheck()
|
|
}
|
|
|
|
function statuscheck(){
|
|
// Console Feedback
|
|
console.log("%cUSERSCRIPT | " + GM_info.script.name + " " + GM_info.script.version + " | successfully initialized", consoleCSS);
|
|
}
|
|
|
|
window.addEventListener('load', () => {
|
|
rewriteLinks();
|
|
});
|