Remove YouTube Share Identifier

Remove the "si" parameter from YouTube share links.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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})})();