Results 1 to 3 of 3

Thread: (Neopets) GM script mod/request : Remove Drop Down Links

  1. #1
    Sugar Rush's Avatar
    Joined
    Sep 2015
    Posts
    307
    Userbars
    6
    Thanks
    669
    Thanked
    433/153
    DL/UL
    27/0
    Mentioned
    28 times
    Time Online
    21d 21h 31m
    Avg. Time Online
    10m

    (Neopets) GM script mod/request : Remove Drop Down Links

    (you need an account to see links) - Can this be modified to remove links, not just add them? For example, I'd like to remove links like Shops � Merchandise, and other useless stuff that clutters up Neopets' drop down links.

    Any help would be greatly appreciated!

  2. #2
    npm's Avatar
    Joined
    Dec 2011
    Posts
    813
    Userbars
    15
    Thanks
    735
    Thanked
    564/219
    DL/UL
    84/3
    Mentioned
    109 times
    Time Online
    83d 21h 28m
    Avg. Time Online
    28m
    Heres my solution, just keep adding the ones you want to remove with the detach(menu[optionIndex]) format the optionIndex its the index starting from 0, to add new elements just follow the format append(menu, option(href, text), location) 'beforeend' so its goes at the end of the list or 'afterbegin' if you want it at the beging. If you need help just PM me. @(you need an account to see links)

    I dont like to use Jquery, so my code might look a little longer but it works

    Code:
    // ==UserScript==
    // @(you need an account to see links)        Neopets DropDown Links Remover
    // @(you need an account to see links)space   com.hectordev
    // @(you need an account to see links)cription Removes Neopets DropDown Links
    // @include     *.neopets.com/*
    // @version     1
    // @grant       none
    // ==/UserScript==
    (function() { 'use strict';
                 
    var $ = function $(selector, context){
        return context === undefined ? document.querySelector(selector) : context.querySelector(selector); 
    },
    $$ = function $$(selector, context){
      return (context === undefined) ? document.querySelectorAll(selector) : context.querySelectorAll(selector); 
    },
    detach = function detach(element){
      var parent = element.parentNode;
      if (!parent) { return; }
      parent.removeChild(element);
      return element;
    },
    append = function append(parent, element, where){
         parent.insertAdjacentElement(where, element);
    },
    option = function option(href, text){
       var li = document.createElement('li');
       var a = document.createElement('a');
       a.innerHTML =  "� " + text;
       a.href = href;
       append(li, a, 'beforeend');
       return li;
    }
       
    var nav = $$('.dropdown', $('#template_nav'));
    
    // USE THESE TO ADD
    var myaccount = nav[0];
    var customise = nav[1];
    var games = nav[2];
    var explore = nav[3];
    var news = nav[4];
    var community = nav[5];
    var shops = nav[6];
    var ncmall = nav[7];
    var premium = nav[8];
    
    // USE THESE TO REMOVE
    var myaccountMenu = $$('li', myaccount);
    var customiseMenu = $$('li', customise);
    var gamesMenu = $$('li', games);
    var exploreMenu = $$('li', explore);
    var newsMenu = $$('li', news);
    var communityMenu = $$('li', community);
    var shopsMenu = $$('li', shops);
    var ncmallMenu = $$('li', ncmall);
    var premiumMenu = $$('li', premium);
    
    // ======================= REMOVES
    detach(myaccountMenu[0]); // control panel
    detach(myaccountMenu[1]); // preferences
    detach(customiseMenu[5]); // pound
    detach(gamesMenu[1]); // popular
                 
    // keep adding.
    
    
    // ======================= ADD
    
    append(myaccount, option('http://www.neopets.com/gallery/index.phtml', 'Gallery Index'), 'beforeend'); // inserts new element into my account at the end.
    append(games, option('http://www.neopets.com/safetydeposit.phtml', 'SBD'), 'afterbegin'); // inserts new element into games at the begin.
    
    
    })(this);
    Last edited by npm; 10-11-2017 at 03:35 PM.

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

    Nyu (10-12-2017),Pusheen (10-11-2017),Sugar Rush (10-11-2017)

  4. #3
    Sugar Rush's Avatar
    Joined
    Sep 2015
    Posts
    307
    Userbars
    6
    Thanks
    669
    Thanked
    433/153
    DL/UL
    27/0
    Mentioned
    28 times
    Time Online
    21d 21h 31m
    Avg. Time Online
    10m
    That works perfectly! Thank you! +rep'd

  5. The Following User Says Thank You to Sugar Rush For This Useful Post:

    npm (10-11-2017)

Posting Permissions

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