Youtube Playlist Nullifier

Open videos in a playlist by themselves by removing the &list parameter from links.

// ==UserScript==
// @name         Youtube Playlist Nullifier
// @namespace    Amaroq64
// @version      0.1
// @description  Open videos in a playlist by themselves by removing the &list parameter from links.
// @author       Amaroq
// @match        https://www.youtube.com/playlist*
// @icon         https://www.youtube.com/favicon.ico
// @grant        none
// @run-at document-idle
// ==/UserScript==

(function()
{
    'use strict';

    function cleanLinks()
    {
        //Duplicate IDs on the same page are invalid html, but youtube does it anyway.
        //However, this is probably the most reliable way to get the correct links.
        let links = document.querySelectorAll('a#video-title');

        for (let link = 0; link < links.length; link++)
        {
            //Keep everything before the first &.
            //A simple split will do.
            if(!links[link].dataset.cleaned)
            {
                links[link].href = links[link].href.split('&')[0];
                links[link].dataset.cleaned = 'true';
            }
        }
    }

    var observer = new MutationObserver(cleanLinks);
    observer.observe(document.body, { childList: true, subtree: true });
})();