I desperately need help with writing a Tampermonkey/Greasemonkey script that takes part of the information within the web page and makes it part of the page (and window) title.
A client's name is part of the target (internal) web page, and clearly labeled within the HTML:
<div id="patient-info" class="ehr-patients-info">
<div id="patient-identification">
<span title="" id="patient-name">
Johnnyfirst
Smithylast
</span>
</div>
...
I want to add the text "Johnnyfirst Smithylast" to the window title and tried:
var ptname = document.getElementById("patient-name") ;
document.title = document.title + " | Name: " + ptname ;
But that resulted in titles like: ...| Name: null
.
The second problem is that the web site to which I am piggybacking this userscript doesn't load all at once. After the initial page load, there's heavy javascript functionality which loads various parts of the page and ends up displaying the client name as above.
When I try $(window).on('load', function() { ... })
or $(document).ready()
, it seems to be acting on a preliminary version of the web page that doesn't have the information fully loaded yet.
Johnnyfirst Smithylast
` In your code, you have the "#" in front of the patient name. Does that mean to look for "id=" in the tag? Is there another character that means look for "class=" in the tag, such as "class=patient-name ng-binding"? – kwantum Jul 07 '19 at 11:27`. I see that your waitForKeyElements() function already does that if I give an iframeSelector. How do I specify an iframeSelector? The website seems to use iframes, but there is no actual `
– kwantum Jul 07 '19 at 14:26