Greasy Fork is available in English.
Redirects x.com to twitter.com and enforces ?mx=1 on all URLs.
当前为
// ==UserScript==
// @name ForceTwitterURL
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Redirects x.com to twitter.com and enforces ?mx=1 on all URLs.
// @author nyathea
// @match https://x.com/*
// @match https://twitter.com/*
// @grant none
// @license MIT
// ==/UserScript==
(function() {
'use strict';
const currentUrl = window.location.href;
// Function to redirect to twitter.com with ?mx=1
const redirectToTwitterWithMx = (path = '/home') => {
const newUrl = `https://twitter.com${path}?mx=1`;
window.location.replace(newUrl);
};
if (currentUrl.startsWith('https://x.com')) {
// Redirect x.com to twitter.com with ?mx=1
const path = window.location.pathname || '/home';
redirectToTwitterWithMx(path);
} else if (currentUrl.startsWith('https://twitter.com')) {
// Ensure ?mx=1 is appended and redirect to /home if just twitter.com
if (!currentUrl.includes('?mx=1')) {
const path = window.location.pathname || '/home';
redirectToTwitterWithMx(path);
} else if (currentUrl === 'https://twitter.com/') {
redirectToTwitterWithMx('/home');
}
}
})();