Last active
June 29, 2023 21:39
-
-
Save tobbez/21181ca2458219beef53f20e04c067ea to your computer and use it in GitHub Desktop.
Redirect all twitter URLs to the mobile site
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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}`); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks! Works like a charm!