下面的脚本可以在Firefox/Greasemonkey中使用,但是Chrome/Tamper猴子不会发生任何事情。
有人能明白为什么它在坦佩莫克不起作用吗?
// ==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();发布于 2016-11-29 19:00:52
问题代码在两种浏览器中都不应该工作,您应该在控制台中看到错误消息。
问题:
document.getElementById('survey16') method.这是一个jQuery函数。removeSurvey()应该是:
函数removeSurvey (jNode) { jNode.hide ();//- .hide是一个jQuery函数。}waitForKeyElements调用和removeSurvey之间存在不匹配。
在第一个过程中,您使用类survey16搜索一个div,而在第二个过程中,您尝试使用id survey16删除一个元素。到底是哪一个?@grant none时,不要使用@require,这通常会导致页面冲突和崩溃。jQuery is especially bad.@grant none在两种浏览器中的功能略有不同。使用@require时,除特殊和罕见的情况外,请指定@grant GM_addStyle。https://stackoverflow.com/questions/40870609
复制相似问题