I'm trying to use GreaseMonkey on a page that uses AJAX. I found what seems to be the solution for waiting and evaluating elements as they appear in "waitForKeyElements"
However, my console returns "waitForKeyElements is undefined"
here's the code:
// ==UserScript==
// @name SalesForce helper
// @namespace https://c.na3.visual.force.com*
// @include https://c.na3.visual.force.com*
// @include https://na3.salesforce.com/*
// @grant none
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js
// ==/UserScript==
if(window.location.href.match("salesforce.com/500?")){
waitForKeyElements(".listBody div",Greasemonkey_main);
}
function Greasemonkey_main () {
alert(window.location.href);
if(window.location.href.match("salesforce.com/500?")){
var firstWords = ["Edit","Base","Accelerated","EU","GoLive","Redesign","Report"]
var divs = document.getElementsByTagName("div");
for(var i = 0;i < divs.length;i++){
var did = divs[i].id;
if(did.indexOf("CASES_SUBJECT") > 0){
var dSpan = divs[i].getElementsByTagName("span")[0];
var subject = divs[i].getElementsByTagName("span")[0].innerHTML.split(" ")[0];
if(firstWords.indexOf(subject) < 0){
//alert("howdy = " + subject);
dSpan.style = "background-color:yellow";
}
}
}
}
}
I figured it out. In all of the research and examples of this function that I found, I never realized that it was a separate script that needed to be included.
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With