There’s probably a more elegant way but this works…
// Find all links..
let allLinks = document.querySelectorAll("a");
// Loop through all links, find the text of the element two elements prior, and insert the text into the href.
allLinks.forEach(a => {
const strongText = a.previousSibling.previousSibling.innerText;
a.href = a.href.replace("q=", "q=" + strongText);
});
I don’t think this is possible to do with any editor. You need some kind of program/script which is doing that for you.
Maybe the easiest way is to use Excel and just write a small VBA macro. But at the end you need some programming skills to make this happen.
I’m sorry. When you talked about FOR/NEXT and DO/WHILE, I thought that you were looking for a scripted solution.
The one I gave you was pure javascript. All you would need to do is add this to the bottom of your page (you could put this right before the </body> closing tag)
<script>
// Find all links..
let allLinks = document.querySelectorAll("a");
// Loop through all links, find the text of the element two elements prior, and insert the text into the href.
allLinks.forEach(a => {
const strongText = a.previousSibling.previousSibling.innerText;
a.href = a.href.replace("q=", "q=" + strongText);
});
</script>
If you want to do it in notepad++, you’d have to use some sort of regular expression (not my strong suit) on a find/replace