Is it possible to write a script in greasemonkey that will find specific/mentioned keyword on the list of given links for example a page has 10 links and am looking for word "ramp" and on those 10links can it go and highlight the links that has word "ramp" ?
-
2Welcome to StackOverflow! This is a rather broad question; you might want to post some code examples of what you currently have and a more detailed explanation of the problems you're facing. Thanks!Hatchet– Hatchet2016-01-31 23:13:52 +00:00Commented Jan 31, 2016 at 23:13
-
Yes that is possibleQBM5– QBM52016-01-31 23:14:17 +00:00Commented Jan 31, 2016 at 23:14
Add a comment
|
1 Answer
I can't comment as I don't have enough reputation. As the other say, your question should not be asked this way. I assume that you don't know Javascript, so here is a quick and dirty code that solves your issue.
"use strict";
var links = document.getElementsByTagName("a");
for (let i=0; i<links.length; i++) {
let link = links[i];
link.innerHTML = link.innerHTML.replace("ramp", "<span style='background-color: yellow;'>ramp</span>");
}
Now that you have the code, I advice you to spend some time on the following links: https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByTagName https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML https://developer.mozilla.org/en-US/docs/Web/HTML/Element/span
1 Comment
SSH
Thank You for the support .