Suppress YouTube Playlist links

When opening a video from a playlist, strip out the parameters that make it open in a playlist UI

// ==UserScript==
// @name         Suppress YouTube Playlist links
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  When opening a video from a playlist, strip out the parameters that make it open in a playlist UI
// @license MIT
// @author       Igor Makarov
// @match        *://*.youtube.com/playlist*
// @match        *://*.youtube.com/feed/history*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @require      https://code.jquery.com/jquery-latest.js
// ==/UserScript==

var hrefsCount = 0;
function modifyLinks() {
    let hrefs = $('a');
    if (hrefs.length == hrefsCount) {
        return;
    }
    hrefsCount = hrefs.length;
    hrefs.each(function() {
        let href = $(this).attr('href');
        if (!href) {
            return;
        }
        // console.log(`href: ${href}`);
        let url = new URL(href, document.location);
        if (url.searchParams && url.searchParams.has('list')) {
            url.searchParams.delete('list');
        }
        if (url.searchParams && url.searchParams.has('index')) {
            url.searchParams.delete('index');
        }
        //if (url.searchParams && url.searchParams.has('t')) {
        //    url.searchParams.delete('t');
        //}
        if (url.searchParams && url.searchParams.has('pp')) {
            url.searchParams.delete('pp');
        }
        $(this).attr('href', url);
        // console.log(`url: ${url}`);
    });
}

$(document).ready(modifyLinks);
$(document).bind("DOMSubtreeModified", modifyLinks);