Results 1 to 3 of 3

Thread: TM script troubleshoot?

  1. #1
    omg.UFOs's Avatar
    Joined
    Jun 2018
    Posts
    457
    Pronouns
    --------------------
    Userbars
    30
    Thanks
    776
    Thanked
    876/287
    DL/UL
    48/0
    Mentioned
    54 times
    Time Online
    25d 22h 12m
    Avg. Time Online
    17m

    TM script troubleshoot?

    This is not my script. I've had this script for awhile now, it shows the old Neopets toolbar at the top of the screen. Everything works except when im at the Trading Post. When I'm at the Trading post and try to go to my Inventory or My Shop it gives me a 404 error.. It only happens in the Trading post.. Can someone take a look and possibly see whats wrong here?

    Code:
    // ==UserScript==
    // @name         Neopets old shop toolbar
    // @namespace    http://tampermonkey.net/
    // @version      0.2
    // @description  Changes shops links to old shop toolbar
    // @author       juvian123
    // @match        http://www.neopets.com/*
    // @grant        none
    // @run-at       document-end
    // ==/UserScript==
    
    (function() {
    	var toolbar = $(`<div style="text-align:center">
    <img src="https://i.imgur.com/ym2y3Nc.gif" alt="" usemap="#shopbar" />
    <map name="shopbar">
        <area shape="poly" coords="503, 68, 503, 43, 520, 46, 524, 66" />
        <area shape="poly" coords="469, 66, 468, 41, 498, 45, 498, 63" />
        <area shape="poly" coords="435, 38, 442, 65, 461, 67, 467, 38" />
        <area shape="poly" coords="407, 64, 409, 40, 434, 44, 437, 66, 408, 71" />
        <area shape="poly" coords="384, 58, 383, 36, 406, 34, 400, 64" />
        <area shape="poly" coords="360, 64, 360, 38, 379, 36, 379, 60" />
        <area shape="poly" coords="339, 60, 333, 33, 353, 30, 357, 59" />
        <area shape="poly" coords="311, 61, 310, 34, 329, 33, 334, 64" />
        <area shape="poly" coords="248, 56, 300, 55, 300, 81, 277, 110, 255, 100" />
        <area shape="poly" coords="248, 54, 259, 7, 286, 9, 303, 55" />
        <area shape="poly" coords="208, 66, 211, 40, 238, 42, 241, 73" />
        <area shape="poly" coords="189, 73, 186, 40, 205, 40, 205, 73" />
        <area shape="poly" coords="159, 77, 151, 42, 181, 42, 183, 74" />
        <area shape="poly" coords="131, 74, 119, 46, 143, 43, 154, 77" />
        <area shape="poly" coords="85, 77, 90, 42, 115, 49, 128, 78" />
        <area shape="poly" coords="55, 80, 58, 50, 82, 56, 79, 80" />
        <area shape="poly" coords="30, 49, 40, 42, 52, 49, 52, 67, 39, 73, 29, 66" />
    </map>
    </div>`)
    var links = ['inventory.phtml', 'market.phtml?type=your', '/guilds/index.phtml', '/auctions.phtml', '/noticeboard.phtml', '/market.phtml?type=wizard', '/battledome/battledome.phtml', '/objects.phtml', '/market_map.phtml', '/soupkitchen.phtml', '/market_plaza.phtml', '/stockmarket.phtml?type=list&search=%&bargain=true', '/bank.phtml', '/island/tradingpost.phtml', '/donations.phtml', '/safetydeposit.phtml', '/neohome.phtml']
    var alts = ['Inventory', 'My shop', 'Guild', 'Auctions', 'Noticeboard', 'Shop Wizard', 'Battledome', 'Neopia Central', 'Market Map', 'Soup Kitchen', 'The Neopian Plaza', 'Stock Market', 'Bank', 'Trading Post', 'Money Tree', 'Safety Deposit Box', 'Neohome']
    
    $("a[href='/market.phtml?type=wizard']").parent().filter(function(){return $(this).parents("ul").length == 0}).replaceWith(toolbar);
    	toolbar.find('area').each(function(){
    $(this).attr("title", alts[links.length - $(this).index() - 1])
    $(this).attr("href", links[links.length - $(this).index() - 1])
    	});
    })();

  2. #2
    *squeak*
    Bat's Avatar
    Joined
    Nov 2012
    Posts
    4,037
    Userbars
    153
    Thanks
    2,147
    Thanked
    46,339/3,558
    DL/UL
    34/1
    Mentioned
    1,751 times
    Time Online
    644d 29m
    Avg. Time Online
    3h 42m
    TL;DR - add / to the beginning of the links that you're having issues with.

    The addresses for your inventory and shop in the "links" array are missing a forward-slash ( / ) at the beginning which tells the browser that those pages are in the site's root directory. The rest of the links start out with a forward-slash, so the browser interprets them properly no matter where you are on the site.

    For example, the Trading Post link looks like:

    /island/tradingpost.phtml

    So the browser interprets the address like:

    http://www.neopets.com/island/tradingpost.phtml

    Your inventory link looks like:

    inventory.phtml

    So, as long as your current location on the site is in the root directory at http://www.neopets.com/, the browser interprets the address like:

    http://www.neopets.com/inventory.phtml

    However, when you're not in the root directory, like when you're visiting any of the Neopian Worlds or navigating the games section, the browser interprets the address to your inventory to be relative to the current directory you're in. For example, if you're visiting the Trading Post, your current directory is http://www.neopets.com/island/, so the browser interprets the location of your inventory to be:

    http://www.neopets.com/island/inventory.phtml

  3. The Following 3 Users Say Thank You to Bat For This Useful Post:

    Caylen (05-04-2020),Flordibel (05-04-2020),omg.UFOs (05-04-2020)

  4. #3
    omg.UFOs's Avatar
    Joined
    Jun 2018
    Posts
    457
    Pronouns
    --------------------
    Userbars
    30
    Thanks
    776
    Thanked
    876/287
    DL/UL
    48/0
    Mentioned
    54 times
    Time Online
    25d 22h 12m
    Avg. Time Online
    17m
    Wow, that worked! ive been just letting this issue go for like 2 yrs now, who knew the solution was so simple! Thank you!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •