This is for a greasemonkey userscript within Firefox (Waterfox).
We have a cloud database (CRM Dynamics) which, in order to load a particular record, the browser performs three page loads with different urls and parameters.
I want to fetch parameters from one of those page loads (the one that loads in the middle) and display it on the page somewhere for reference. So I created a div that fits right below the main ribbon.
The problem is that, since the page loads three times, that means the script loads three times, so I use GM_getValue
and GM_setValue
to store and retrieve data on the subsequent pageloads.
However, it's worse than that.
Is there a way to put my toolbar-div in the browser's DOM instead of the page's DOM? That way there could be a place where each page load has access to.
What I want to do is somehow get the first page load to do something after the third page load has finished.
Figured it out! Brock Adam's comment let me to a solution. Thanks, Brock.
So I figure the code to run on the first page load and make sure it does this:
$(window).on('load', function () {
console.log('updating itemid');
$('#myd').text(GM_getValue("itemid"));
});
The window.load
event fires on each page load, so when the last pageload runs, it triggers this loading event and updates the div text. Apparently, this event doesn't fire until after the third pageload is complete.