Created
April 28, 2024 12:57
-
-
Save tyhallcsu/6234e3a236f4fb875c4af99577c813e6 to your computer and use it in GitHub Desktop.
Automatically clean and redirect from tracking URLs in Reddit mail links.
This file contains hidden or 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 Reddit Mail Redirect Cleaner | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Automatically clean and redirect from tracking URLs in Reddit mail links. | |
// @author sharmanhall | |
// @match *://*/* | |
// @grant none | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=reddit.com | |
// @run-at document-end | |
// @license MIT | |
// @downloadURL https://update.greasyfork.org/scripts/493675/Reddit%20Mail%20Redirect%20Cleaner.user.js | |
// @updateURL https://update.greasyfork.org/scripts/493675/Reddit%20Mail%20Redirect%20Cleaner.meta.js | |
// ==/UserScript== | |
// | |
// GreasyFork URL: https://greasyfork.org/en/scripts/493675-reddit-mail-redirect-cleaner | |
(function() { | |
'use strict'; | |
// Listen for click events on the entire document | |
document.addEventListener('click', function(e) { | |
// Check if the clicked element is a link that includes "click.redditmail.com" | |
var target = e.target.closest('a[href*="click.redditmail.com"]'); | |
if (target) { | |
// Prevent the default link behavior | |
e.preventDefault(); | |
// Decode the URL and extract the direct Reddit link | |
const url = new URL(decodeURIComponent(target.href)); | |
const redditURLMatch = url.href.match(/https:\/\/www\.reddit\.com\/message\/messages\/[a-zA-Z0-9]+/); | |
if (redditURLMatch) { | |
// Redirect to the extracted Reddit URL | |
window.location.href = redditURLMatch[0]; | |
} else { | |
// Alert the user if no clean URL is found | |
alert("Could not find a clean URL to redirect to."); | |
} | |
} | |
}, true); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
GreasyFork Write-up:
Title: Reddit Mail Redirect Cleaner
Description:
This userscript enhances your browsing experience by automatically cleaning and redirecting from tracking URLs found in Reddit mail links. When clicking on a Reddit mail link that routes through
click.redditmail.com
, this script intercepts the link, removes tracking parameters, and directly navigates to the intended Reddit message. This not only speeds up your access but also protects your privacy by avoiding unnecessary tracking.Features:
Installation:
This script is particularly useful for Reddit users who frequently check private messages and want to avoid the clutter of tracking URLs. It's designed to work silently in the background, providing a cleaner and faster browsing experience.
License: MIT
GreasyFork: https://greasyfork.org/en/scripts/493675-reddit-mail-redirect-cleaner