您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Automatically clean and redirect from tracking URLs in Reddit mail links.
当前为
- // ==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
- // ==/UserScript==
- (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);
- })();