I have a userscript that modifies the href of all applicable links on an an IP-direct, Google search page:
// ==UserScript==
// @name _Modify select Google search links
// @include http://YOUR_SERVER.COM/YOUR_PATH/*
// @include http://62.0.54.118/*
// ==/UserScript==
var qLinks = document.querySelectorAll ("a[href*='?q=']");
for (var J = qLinks.length - 1; J >= 0; --J) {
var oldHref = qLinks[J].getAttribute ('href');
var newHref = oldHref.replace (/\?q=/, "?&q=");
//console.log (oldHref + "\n" + newHref);
qLinks[J].setAttribute ('href', newHref);
}
It works fine on the first page, but when I use the pagination links, it stops working -- because the new pages are loaded by AJAX.
@Brock Adams told me to use waitForKeyElements()
but I couldn't figure out how to do it.
I have seen a few topics, like stackoverflow.com/questions/10888326/executing-javascript-script-after-ajax-loaded-a-page-doesnt-work, but I can't figure out how to use them.
How can I use that script to change links on an AJAX page like:
http://62.0.54.118/search?&q=42&oq=42&sourceid=chrome&ie=UTF-8&filter=0#filter=0&q=42&start=10