Skip to content

Instantly share code, notes, and snippets.

@tobbez
Last active June 29, 2023 21:39
Show Gist options
  • Save tobbez/21181ca2458219beef53f20e04c067ea to your computer and use it in GitHub Desktop.
Save tobbez/21181ca2458219beef53f20e04c067ea to your computer and use it in GitHub Desktop.
Redirect all twitter URLs to the mobile site
// ==UserScript==
// @name Twitter: Redirect to mobile
// @namespace http://ryara.net/
// @version 0.1
// @author tobbez
// @match https://twitter.com/*
// @grant none
// @run-at document-start
// @downloadURL https://gist.github.com/tobbez/21181ca2458219beef53f20e04c067ea/raw/twitter-redirect-mobile.user.js
// @updateURL https://gist.github.com/tobbez/21181ca2458219beef53f20e04c067ea/raw/twitter-redirect-mobile.user.js
// ==/UserScript==
(function() {
'use strict';
let l = document.location;
let host = 'mobile.twitter.com';
if (l.port.length > 0) host += `:${l.port}`;
let pathname = l.pathname;
if (pathname == '/search-home') pathname = '/search';
document.location.replace(`${l.protocol}//${host}${pathname}${l.search}${l.hash}`);
})();
@zomars
Copy link

zomars commented Feb 13, 2018

Thanks! Works like a charm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment