123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- // ==UserScript==
- // @name Twitter to Nitter
- // @author Jesús E.
- // @namespace NitterRedirect
- // @description Scan page for Twitter and urls replace with Nitter
- // @homepageURL https://git.sr.ht/~heckyel/book/blob/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.4
- // @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
- 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;
- }
- }
- log('successfully initialized');
- }
- window.addEventListener('load', () => {
- rewriteLinks();
- });
|