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.0
// @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'];
// Patch select
const originalSelect = HTMLTextAreaElement.prototype.select;
HTMLTextAreaElement.prototype.select = function () {
const url = this.value; // Value in textarea to copy
const params = new URL(url); // Url
paramsToDelete.forEach(param => params.searchParams.delete(param)); // Delete params
this.value = params.href; // Value modded
return originalSelect.apply(this, arguments);
};