An auto-highlighting program?

Discussion in 'Neopets Program Discussion' started by lanabubalo13, Apr 28, 2009.

  1. lanabubalo13

    lanabubalo13 Level II

    Joined:
    Mar 17, 2009
    Messages:
    158
    Likes Received:
    6
    Would it be possible to make an auto-highlighting program? Like, when a page loads, the program would auto-highlight items priced 5k and 10k. This would make it easier to RS in shops like Book, Food, and Clothing for all the non-ABing people out there. Just my two cents :p
     
  2. Freestyle

    Freestyle Level II

    Joined:
    Oct 21, 2007
    Messages:
    235
    Likes Received:
    8
    I could make a GreaseMonkey Script to do that but it would involve letting the page load fully first.
     
  3. lanabubalo13

    lanabubalo13 Level II

    Joined:
    Mar 17, 2009
    Messages:
    158
    Likes Received:
    6
    Fully load, as in not having Adblock block anything, or just waiting for everything that "should" load through Adblock load :eek:
     
  4. Freestyle

    Freestyle Level II

    Joined:
    Oct 21, 2007
    Messages:
    235
    Likes Received:
    8
    Well if you had adblock going then it wouldnt have to wait to load the images. But the page would still need to load fully before it highlights it.
     
  5. lanabubalo13

    lanabubalo13 Level II

    Joined:
    Mar 17, 2009
    Messages:
    158
    Likes Received:
    6
    Oh I'm fine with that; PM for a price or something? :)
     
  6. Brian

    Brian Level I

    Joined:
    Apr 14, 2009
    Messages:
    92
    Likes Received:
    8
    Location:
    Daytona Beach, FL
    test 2500
    5000
    7500
    10000
    credits to the guy who made it.

    // ==UserScript==
    // @name Highlight Words
    // @namespace http://wtwf.com/
    // @description Adds a way to popup stuff on select boxes
    // @include *

    // ==/UserScript==

    (function() {

    // key: word to match, value a dictionary of style elements to apply
    // to blocks containing that word.
    const COLOR_MAP = {
    "2500": {"color": "red"},
    "5000": {"color": "red"},
    "7500": {"color": "red"},
    "10000": {"color": "red"},
    };

    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 COLOR_MAP) {
    if (ele.nodeValue.toLowerCase().indexOf(key) != -1) {
    // TODO(ark) perhaps make it only highlight the word?
    var span = document.createElement("span");
    ele.parentNode.replaceChild(span, ele);
    span.appendChild(ele);
    for (var css in COLOR_MAP[key]) {
    span.style[css] = COLOR_MAP[key][css];
    }
    }
    }
    }
    }

    highlightText();
    })();
     
    lanabubalo13 likes this.
  7. lanabubalo13

    lanabubalo13 Level II

    Joined:
    Mar 17, 2009
    Messages:
    158
    Likes Received:
    6
    Thanks :)

    For those that want to use this like me, just add commas in the 2500, 5000, 7500, and 10000 in the script where they should go :D