What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Greasemonkey message box / redirect

Greasemonkey message box / redirect
Author: Message:
stoshrocket
Senior Member
****

Avatar
formerly methos

Posts: 748
Reputation: 31
33 / Male / Flag
Joined: Aug 2005
RE: Greasemonkey message box / redirect
To prevent alert spamming you could just build in a variable in place of the alert that is changed to 1 when a word is found, then after the search has been made, check the variable, if = 1, alert...

Javascript code:
    // ==UserScript==
    // @name          Alert
    // @namespace     http://sammyservers.com
    // @description   Alert
    // @include   *
     
    // ==/UserScript==
     
    (function() {
     
    const WORD = {
      "test": {"color": "red"},
    };
   
    //build in the global variable...
    var j = 0;
     
    function highlightText() {
     
      var allTextNodes = document.evaluate('//text()', document, null,
                                           XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
                                           null);
     
      for (var i = 0; i < allTextNodes.snapshotLength; i++) {
        var ele = allTextNodes.snapshotItem(i);
        for (var key in WORD) {
       
          if (ele.nodeValue.toLowerCase().indexOf(key) != -1) {
            var span = document.createElement("span");
            ele.parentNode.replaceChild(span, ele);
            span.appendChild(ele);
       
            for (var css in WORD[key]) {
              span.style[css] = WORD[key][css];
              //changes the global variable to 1
              j = 1;        
            }
          }
        }
      }
    }
      highlightText();
      if(j = 1){
        alert("test");
      }
    })();


I'm, not too strong on the javascript front so the code might not be solid, but in theory it should work!

As for searching the word outside of the source I have no clue...
formerly methos
01-17-2010 11:44 AM
Profile PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Greasemonkey message box / redirect - by Jimbo on 01-16-2010 at 11:14 PM
RE: Greasemonkey message box / redirect - by andrey on 01-17-2010 at 12:21 AM
RE: Greasemonkey message box / redirect - by Jimbo on 01-17-2010 at 12:52 AM
RE: Greasemonkey message box / redirect - by stoshrocket on 01-17-2010 at 11:44 AM
RE: Greasemonkey message box / redirect - by Jimbo on 01-17-2010 at 01:38 PM
RE: Greasemonkey message box / redirect - by stoshrocket on 01-17-2010 at 03:52 PM
RE: Greasemonkey message box / redirect - by Jimbo on 01-17-2010 at 04:46 PM
RE: Greasemonkey message box / redirect - by stoshrocket on 01-17-2010 at 05:23 PM
RE: RE: Greasemonkey message box / redirect - by Jimbo on 01-17-2010 at 05:40 PM
RE: Greasemonkey message box / redirect - by andrey on 01-17-2010 at 06:42 PM
RE: Greasemonkey message box / redirect - by Jimbo on 01-17-2010 at 07:02 PM
RE: Greasemonkey message box / redirect - by kezz on 01-17-2010 at 10:01 PM
RE: Greasemonkey message box / redirect - by Jimbo on 01-17-2010 at 10:08 PM
RE: Greasemonkey message box / redirect - by andrey on 01-17-2010 at 11:32 PM
RE: Greasemonkey message box / redirect - by Jimbo on 01-18-2010 at 12:10 AM
RE: Greasemonkey message box / redirect - by andrey on 01-18-2010 at 12:29 AM
RE: Greasemonkey message box / redirect - by Jimbo on 01-18-2010 at 12:49 AM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On