我问了一个问题并在这里得到了答案:如何从Greasemonkey调用此YouTube功能?
该代码可以工作并向页面添加一个按钮,用于捕获视频时间.
但是,关键部分必须在目标页面范围内运行 - 其中Greasemonkey的GM_功能不可用.
我想用来GM_setValue()录制视频时间.如何GM_setValue()从我的按钮click处理程序中调用?
... ...
//-- Only run in the top page, not the various iframes.
if (window.top === window.self) {
var timeBtn = document.createElement ('a');
timeBtn.id = "gmTimeBtn";
timeBtn.textContent = "Time";
//-- Button is styled using CSS, in GM_addStyle, below.
document.body.appendChild (timeBtn);
addJS_Node (null, null, activateTimeButton);
}
function activateTimeButton () {
var timeBtn = document.getElementById ("gmTimeBtn");
if (timeBtn) {
timeBtn.addEventListener ('click',
function …Run Code Online (Sandbox Code Playgroud) 基本上就是问题标题。这将使我受益匪浅。我希望能够访问GM_getValue用户脚本之外的内容以进行调试,或者至少访问值和名称本身。
我在 Windows 10 上使用 Chrome。