Skip to content

Instantly share code, notes, and snippets.

@albertopasqualetto
Last active October 6, 2024 13:28
Show Gist options
  • Save albertopasqualetto/392bbcc71da511164ede09b4e94a0392 to your computer and use it in GitHub Desktop.
Save albertopasqualetto/392bbcc71da511164ede09b4e94a0392 to your computer and use it in GitHub Desktop.
Remove translation parameter from Reddit url userscript
// ==UserScript==
// @name Reddit remove translation
// @namespace albertopasqualetto
// @version 1.0.0
// @description Remove translation parameter from Reddit url
// @author albertopasqualetto
// @match *://sh.reddit.com/*
// @match *://*.reddit.com/*
// @exclude *://new.reddit.com/*
// @exclude *://old.reddit.com/*
// @icon https://www.redditstatic.com/desktop2x/img/favicon/android-icon-192x192.png
// @grant none
// @run-at document-idle
// @downloadURL https://gist.github.com/albertopasqualetto/392bbcc71da511164ede09b4e94a0392/raw/remove%2520reddit%2520translation.user.js
// @updateURL https://gist.github.com/albertopasqualetto/392bbcc71da511164ede09b4e94a0392/raw/remove%2520reddit%2520translation.user.js
// ==/UserScript==
let current_url = document.location.href;
let t_param_pos = current_url.indexOf('tl=');
if(t_param_pos != -1){
let new_url = current_url.substring(0, t_param_pos) + current_url.substring(t_param_pos + 6);
if(new_url.slice(-1) === "?"){
new_url = new_url.substring(0, new_url.length - 1);
}
location.replace(new_url);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment