Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Highlight
- // @namespace http://fluidapp.com
- // @description What does this do?
- // @include *
- // @author Someone
- // ==/UserScript==
- (function () {
- if (window.fluid) {
- setInterval(function () {
- highlightWord(document.body,'WordPress');
- highlightWord(document.body,'Minnesota');
- highlightWord(document.body,'Mac');
- highlightWord(document.body,'free');
- highlightWord(document.body,'Free');
- highlightWord(document.body,'Apple');
- function highlightWord(root,word){
- textNodesUnder(root).forEach(highlightWords);
- function textNodesUnder(root){
- var walk=document.createTreeWalker(root,NodeFilter.SHOW_TEXT,null,false),
- text=[], node;
- while(node=walk.nextNode()) text.push(node);
- return text;
- }
- function highlightWords(n){
- for (var i; (i=n.nodeValue.indexOf(word,i)) > -1; n=after){
- var after = n.splitText(i+word.length);
- var highlighted = n.splitText(i);
- var span = document.createElement('span');
- span.className = 'highlighted';
- span.appendChild(highlighted);
- after.parentNode.insertBefore(span,after);
- }
- }
- }
- }, 10000)
- }
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement