Skip to content

Instantly share code, notes, and snippets.

@dobladov
Created January 7, 2026 12:00
Show Gist options
  • Select an option

  • Save dobladov/62c4be59d774347cb480b115969a5f72 to your computer and use it in GitHub Desktop.

Select an option

Save dobladov/62c4be59d774347cb480b115969a5f72 to your computer and use it in GitHub Desktop.
Redirect X/twitter to xcancel
// ==UserScript==
// @name Redirect X/Twitter to XCancel
// @namespace http://tampermonkey.net/
// @version 1.1
// @description Redirects x.com and twitter.com URLs to xcancel.com
// @author You
// @match *://x.com/*
// @match *://www.x.com/*
// @match *://twitter.com/*
// @match *://www.twitter.com/*
// @match *://mobile.x.com/*
// @match *://mobile.twitter.com/*
// @grant none
// @run-at document-start
// ==/UserScript==
(function() {
'use strict';
const TARGET_HOST = 'xcancel.com';
// Prevent infinite loops if the script somehow runs on the target domain
if (window.location.hostname === TARGET_HOST) return;
const url = new URL(window.location.href);
url.hostname = TARGET_HOST;
url.protocol = 'https:'; // Ensure HTTPS
// Perform the redirect
window.location.replace(url.toString());
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment