PDA

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



Sugar Rush
10-10-2017, 09:16 PM
jkingaround's DropDown Links ([Only registered and activated users can 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!

npm
10-11-2017, 09:57 AM
[Only registered and activated users can see links]

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



// ==UserScript==
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
// ==/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('[Only registered and activated users can see links]', 'Gallery Index'), 'beforeend'); // inserts new element into my account at the end.
append(games, option('[Only registered and activated users can see links]', 'SBD'), 'afterbegin'); // inserts new element into games at the begin.


})(this);

Sugar Rush
10-11-2017, 02:29 PM
That works perfectly! Thank you! +rep'd :)