Remove YouTube Share Identifier

Remove the "si" parameter from YouTube share links.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name            Remove YouTube Share Identifier
// @name:vi         Xóa Định Danh Chia Sẻ YouTube
// @namespace       https://greasyfork.org/en/users/1240674-anhkhoakz
// @version         1.1.2
// @match           *://*.youtube.com/watch?v=*
// @license         GPLv3; https://www.gnu.org/licenses/gpl-3.0.html#license-text
// @icon            https://i.imgur.com/f1OgZDI.png
// @grant           none
// @description     Remove the "si" parameter from YouTube share links.
// @description:vi  Xóa tham số "SI" khỏi các liên kết chia sẻ YouTube.
// @author          anhkhoakz; https://www.anhkhoakz.dev/
// ==/UserScript==

(()=>{"use strict";const e={DEBOUNCE_DELAY:300,PARAMETER_TO_REMOVE:"si",SELECTORS:{URL_FIELD:"input#share-url",COPY_LINK_RENDERER:"yt-copy-link-renderer"}},n=(e,t)=>{let n;return function(...s){const o=()=>{clearTimeout(n),e(...s)};clearTimeout(n),n=setTimeout(o,t)}},s=e=>{const t=new URL(e);return new URLSearchParams(t.search)},t=t=>{const n=s(t);n.delete(e.PARAMETER_TO_REMOVE);const o=new URL(t);return o.search=n.toString(),o.toString()},o=s=>{if(!s||!(s instanceof HTMLInputElement))return;let o=s.value;const i=n(()=>{if(!s)return;if(s.value===o)return;const e=t(s.value);e!==s.value&&(s.value=e,o=e)},e.DEBOUNCE_DELAY),a=new MutationObserver(i);a.observe(s,{attributes:!0,characterData:!0,subtree:!0})},i=n=>{if(!n||!(n instanceof HTMLElement))return;if(n.tagName.toLowerCase()===e.SELECTORS.COPY_LINK_RENDERER.toLowerCase())return;const s=n.querySelector(e.SELECTORS.URL_FIELD);if(!s)return;s.value=t(s.value),o(s)},a=new MutationObserver(e=>{for(const n of e){const t=n.addedNodes[0];if(!t)continue;i(t)}});a.observe(document.documentElement,{childList:!0,subtree:!0})})();