Greasy Fork is available in English.
Redirect x.com and twitter.com URLs to xcancel.com in address bar. The behaviour of this script changed as it now fires on the windows.location property.
当前为
// ==UserScript==
// @name Redirect X & Twitter to xcancel.com in address bar
// @namespace x.com-xcancel.com-redirect
// @version 2.0.1
// @description Redirect x.com and twitter.com URLs to xcancel.com in address bar. The behaviour of this script changed as it now fires on the windows.location property.
// @author github.com/localhorst
// @license MIT
// @include *://*.x.com/*
// @include *://*.twitter.com/*
// @exclude *://*.x.com/i/*
// @exclude *://*.twitter.com/i/*
// @run-at document-start
// @grant none
// ==/UserScript==
// Enforce strict mode for better code quality
'use strict';
// Declare constant for current URL
const currentUrl = window.location.href;
// Declare constant for old reddit URL
const xCancelUrl = 'https://xcancel.com/';
// Check if the current URL does not include old.x.com
if (currentUrl.includes("twitter.com") || currentUrl.includes("x.com")) {
// Use regex literal and constant for new URL
const newUrl = currentUrl.replace(/^https?:\/\/(www\.)?(x|twitter)\.com\//, xCancelUrl);
// Redirect to new URL without history entry
window.location.replace(newUrl);
}