脚本在 Greasemonkey 中有效,但在 Tampermonkey 中没有任何反应?

Script works in Greasemonkey, but nothing happens in Tampermonkey?

以下脚本在 Firefox/Greasemonkey 中有效,但在 Chrome/Tampermonkey 中没有任何反应。

谁能看出为什么它在 Tampermonkey 中不起作用?

// ==UserScript==
// @name        Example
// @namespace   Example.com
// @description Example.com
// @include     https://example.com/*
// @include     http://example.com/*
// @version     1
// @grant       none
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @require https://greasyfork.org/scripts/5392-waitforkeyelements/code/WaitForKeyElements.js?version=115012
// ==/UserScript==

window.onload = function(){
  document.getElementById('close-cookies').click();
};

waitForKeyElements('div.survey16', removeSurvey);

function removeSurvey() {
  document.getElementById('survey16').hide();
}

$('.chat-bot').hide();

问题代码在任一浏览器中均无效,您应该会在控制台中看到错误消息。

问题:

  1. document.getElementById('survey16')does not have a .hide() method。这是一个 jQuery 函数。
  2. removeSurvey() 应该是:

    function removeSurvey (jNode) {
        jNode.hide ();  //-- .hide is a jQuery function.
    }
    
  3. 除此之外,waitForKeyElements 调用与 removeSurvey 调用不匹配。
    在第一个中,您正在搜索带有 class survey16 的 div,但在第二个中您试图删除带有 [= 的元素31=]idsurvey16。是哪个?
  4. 作为一般规则,不要在同时使用 @require 的同时使用 @grant none,这通常会导致页面冲突和崩溃。 jQuery is especially bad.
  5. 此外,@grant none 在两种浏览器中的功能略有不同。使用 @require 时,请指定 @grant GM_addStyle,特殊且罕见的情况除外。