您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Remove params from share url copied
- // ==UserScript==
- // @name Reddit remove params from share url
- // @namespace https://greasyfork.org/users/821661
- // @match https://*.reddit.com/*
- // @grant none
- // @run-at document-start
- // @version 1.2
- // @author hdyzen
- // @description Remove params from share url copied
- // @license GPL-3.0
- // ==/UserScript==
- 'use strict';
- // Params to delete in url copied
- const paramsToDelete = ['utm_source', 'utm_medium', 'utm_name', 'utm_term', 'utm_content', 'ref', 'ref_source'];
- // Remove params
- function removeParams(url) {
- const params = new URL(url);
- paramsToDelete.forEach(param => params.searchParams.delete(param)); // Delete params
- return params.href; // Value modded
- }
- // Oldreddit
- const originalInputSelect = HTMLInputElement.prototype.select;
- HTMLInputElement.prototype.select = function () {
- this.value = removeParams(this.value);
- return originalInputSelect.apply(this, arguments);
- };
- // Newreddit
- const originalSelect = HTMLTextAreaElement.prototype.select;
- HTMLTextAreaElement.prototype.select = function () {
- this.value = removeParams(this.value);
- return originalSelect.apply(this, arguments);
- };
- // Shreddit
- navigator.clipboard.writeText = function writeText(text) {
- return removeParams(text);
- };