我想补充的参数&vhs=1
,在我的浏览器的每个YouTube视频网址的结尾。 我曾尝试使用下面的脚本尝试,但它陷在一个循环(不断添加&vhs=1
&vhs=1...
)。
// ==UserScript==
// @name Youtube Tape Mode
// @namespace _pc
// @match *://*.youtube.com/watch?*
// @run-at document-start
// ==/UserScript==
var oldUrlPath = window.location.pathname;
/*--- Test that "&vhs=1" is at end of URL, excepting any "hashes"
or searches.
*/
if ( ! /\&vhs=1$/.test (oldUrlPath) ) {
var newURL = window.location.protocol + "//"
+ window.location.hostname
+ oldUrlPath
+ window.location.search.replace + "&vhs=1"
+ window.location.hash
;
/*-- replace() puts the good page in the history instead of the
bad page.
*/
window.location.replace (newURL);
}
任何人都可以提供一些见解和建议,我怎么能为这个目的所写剧本? 我似乎无法弄清楚如何走出死循环的问题。