:tools: Scheduled maintenance

Heads up! Downtime for the Forums, related to the NodeBB upgrade, is planned for Thursday, December 14, starting from 10:00 UTC.
Please make sure to finish all your posts before this time. The downtime should only last for a few minutes.

Migrated 12.11->12.17, now my js doesn't work

  • Hi all!
    I only have a single script that highlights words on the page for me that match the list in the script. He's my script:

    // ==UserScript==
    // @name Highlight Words
    // @author bpm
    // @version 1.1
    // @description Highlights works from an array
    // @include https://www.examplesite.com/*
    // ==/UserScript==
    // 1.1 Updated by Frenzie, added easy to configure wordlist
    (function () {
    var wordlist=[
    /@Wordlist (quote properly and use commas between values)@string@/

    "word 1",
    "word 2",
    "word 3",
    "word 4",

    /@/
    ];
    // other config
    var highlightBgColor = /@Highlight background color@string@/'grey'/@/;
    var highlightColor = /@Highlight font color@string@/'grey'/@/;

    function hilite(text){
    	var count=0,dv;
    	dv=document.defaultView;
    	function searchWithinNode(node,te,len){
    		var pos,skip,spannode,middlebit,endbit,middleclone;
    		skip=0;
    		if(node.nodeType==3){
    			pos=node.data.toUpperCase().indexOf(te);
    			if(pos>=0){
    				spannode=document.createElement('SPAN');
    				spannode.style.backgroundColor=highlightBgColor;
    				spannode.style.color=highlightColor;
    				spannode.style.fontWeight='bold';
    				middlebit=node.splitText(pos);
    				endbit=middlebit.splitText(len);
    				middleclone=middlebit.cloneNode(true);
    				spannode.appendChild(middleclone);
    				middlebit.parentNode.replaceChild(spannode,middlebit);
    				++count;
    				skip=1;
    			}
    		}
    		else if(node.nodeType==1&& node.childNodes && node.tagName.toUpperCase()!='SCRIPT' && node.tagName.toUpperCase!='STYLE'){
    			for (var child=0;child<node.childNodes.length;++child){
    				child=child+searchWithinNode(node.childNodes[child],te,len);
    			}
    		}
    	return skip;
    	}
    	searchWithinNode(document.body,text.toUpperCase(),text.length);
    }
    
    document.addEventListener('DOMContentLoaded',function() {
    	for (i=0; i<wordlist.length; i++) {
    		hilite(wordlist[i]);
    	}
    }, false);
    

    })();

  • Sorry I can't edit my 1st post, here's a tidier version on pastebin:

    http://pastebin.com/e8uRCdQ4

  • My Code on http://pastebin.com/UXHRg4yG works fine for me.

    • check antivirus sioftware interfering with UserJS
    • check other UserJS scripts interfering
    • check Extensions blocking your UserJS
    • check your userJS file name, name the file hilite.js, hilite.user.js does not load the file
    • set path to all your UserJS files with opera:config#UserPrefs|UserJavaScriptFile
    • activate opera:config#UserPrefs|AlwaysLoadUserJavaScript
    • activate opera:config#UserPrefs|UserJavaScript
    • activate UserJS on https sites with opera:config#UserPrefs|UserJavaScriptonHTTPS
  • Found it! (thanks to your bullet point "set path to all your UserJS files with opera:config#UserPrefs|UserJavaScriptFile")

    Noticed 1 small thing below the path to user scripts, remembered that my links were in HTTPS so I enabled a checbox below and wuala! :D

    http://i.imgur.com/0Tm5luD.jpg

    Much love angiesdom ;)

  • Fine.

    Much love angiesdom ;)

    Thanks for the flowers :)

Log in to reply
 

Looks like your connection to Opera forums was lost, please wait while we try to reconnect.