YouTube Remove List from Watch URLs

Remove list parameter from watch links on pages under www.youtube.com/user/.

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        YouTube Remove List from Watch URLs
// @author      Jefferson "jscher2000" Scher
// @namespace   JeffersonScher
// @description Remove list parameter from watch links on pages under www.youtube.com/user/.
// @version     0.1
// @copyright   Copyright 2014 Jefferson Scher
// @license     BSD 3-clause
// @include     http*://www.youtube.com/user/*
// @grant       GM_log
// ==/UserScript==

function cleanseURLs(el){
  var dirty, i, u;
  dirty = el.querySelectorAll("a[href*='/watch?v='][href*='&list=']");
  for (i=0; i<dirty.length; i++){
    u = dirty[i].href;
    dirty[i].href = u.substr(0, u.indexOf("&list="));
  }
}

// run initial cleanse
cleanseURLs(document.body);

// set up mutation observer to detect added videos
var YRLWU_MutOb = (window.MutationObserver) ? window.MutationObserver : window.WebKitMutationObserver;
if (YRLWU_MutOb){
  var YRLWU_chgMon = new YRLWU_MutOb(function(mutationSet){
    mutationSet.forEach(function(mutation){
      for (var i=0; i<mutation.addedNodes.length; i++){
        if (mutation.addedNodes[i].nodeType == 1){
          cleanseURLs(mutation.addedNodes[i]);
        }
      }
    });
  });
  // attach chgMon to document.body
  var opts = {childList: true, subtree: true};
  YRLWU_chgMon.observe(document.body, opts);
}