The below script works in Firefox/Greasemonkey, but nothing happens in Chrome/Tampermonkey.
Can anyone see why it doesn't work in 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();
The question code should not work in either browser and you should see error messages in the consoles.
Problems:
document.getElementById('survey16')
does not have a .hide()
method. That's a jQuery function.removeSurvey()
should be:
function removeSurvey (jNode) {
jNode.hide (); //-- .hide is a jQuery function.
}
waitForKeyElements
call and removeSurvey
.survey16
, but in the second you are trying to delete an element with the id survey16
. Which is it?@grant none
when also using @require
, this usually leads to page conflicts and crashes. jQuery is especially bad.@grant none
functions slightly differently in both browsers. When using @require
, specify @grant GM_addStyle
except in special, and rare, cases.