JSFiddle - React, Tailwind, and code Playground

by Stev Peifer

HTML

<a href="http://www.tip.it/runescape/bestiary/view/1507-guthix-wizard">Bestiary</a>
|
<a href="http://www.tip.it/runescape/?rs2monster_id=387">Bestiary</a>
<p></p>

JavaScript

(
    function($){
        $.bestiaryTooltip=function(){

//~ -------------- NOTE -------------
//~ Create the bestiary object which 
//~ will contain all elements that
//~ contain valid bestiary URLs and a
//~ list of each specific item number
//~ found
//~ ---------------------------------

            var bestiary=new Object();
            bestiary.element=new Array();
            bestiary.number=new Array();
            bestiary.result=new Array();

//~ -------------- NOTE -------------
//~ Create the memory object which
//~ will be used to build the qTips
//~ and hold bestiary information
//~ ---------------------------------

            var memory=new Object();

//~ -------------- NOTE -------------
//~ Iterate through all <A> elements
//~ to build the bestiary object
//~ ---------------------------------

            $('a').each(
                function(){

//~ -------------- NOTE -------------
//~ If the element doesn't contain a
//~ valid bestiary URL, then skip it
//~ ---------------------------------

                    if(!(this.bestiaryNumber=this.href.extractBestiary()))
                        return true;

//~ -------------- NOTE -------------
//~ Add the element to our array of
//~ elements containing valid
//~ bestiary URLs
//~ ---------------------------------

                    bestiary.element.push($(this));

//~ -------------- NOTE -------------
//~ If the current item number isn't
//~ in our list of items then add it
//~ ---------------------------------

                    if($.inArray(this.bestiaryNumber,bestiary.number)==-1)
                        bestiary.number.push(this.bestiaryNumber);
                }  //~ CLOSE: function()
            );  //~ CLOSE: each()

//~ -------------- NOTE -------------
//~ If no elements linking to a
//~ monster were found then don't
//~ bother going any further
//~ ---------------------------------

            if(!bestiary.element&&!bestiary.number)
                return false;

//~...