您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
redirects and rewrites all twitter urls to nitter
- // ==UserScript==
- // @name twitter.com to nitter
- // @description redirects and rewrites all twitter urls to nitter
- // @namespace azzurite
- // @match *://*/*
- // @grant none
- // @version 1.0.0
- // @license GPLv3
- // @author -
- // @run-at document-start
- // ==/UserScript==
- const NITTER_URL = 'nitter.privacydev.net'
- const TWITTER_URL = 'twitter.com'
- function redirectToNitter () {
- document.querySelectorAll('a[href*="'+ TWITTER_URL +'"]').forEach((element) => {
- element.href = element.href.replace(TWITTER_URL, NITTER_URL)
- element.textContent = element.textContent.replace(TWITTER_URL, NITTER_URL)
- })
- }
- if (location.hostname.includes(TWITTER_URL)) location.replace(`https://` + NITTER_URL + location.pathname);
- document.addEventListener(`DOMContentLoaded`, () => {
- (new MutationObserver((mutations) => {
- let runCheck = false
- for (let mutation of mutations) {
- if (mutation.addedNodes.length || mutation.attributeName === 'href') {
- runCheck = true
- break
- }
- }
- if (runCheck) {
- redirectToNitter()
- }
- })).observe(document.querySelector('body'), {attributeFilter: ['href'], childList: true, subtree: true})
- redirectToNitter();
- });