Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name USO Admin Menu
- // @namespace erosman
- // @description Adds Edit Metadata & Edit Code to the Script Menu
- // @updateURL https://userscripts.org/scripts/source/172351.meta.js
- // @downloadURL https://userscripts.org/scripts/source/172351.user.js
- // @include http://userscripts.org/scripts/*
- // @include https://userscripts.org/scripts/*
- // @grant none
- // @author erosman
- // @version 1.0
- // ==/UserScript==
- /* --------- Note ---------
- This script adds Edit Metadata & Edit Code to the Script Menu
- --------- History ---------
- 1.0 Initial release
- */
- (function name() { // anonymous function wrapper, used for error checking to end execution
- "use strict";
- if(window.self !== window.top) return; // end execution if in a frame
- var nav = document.evaluate("//ul[@id='script-nav']/li/a[.='Admin']/../..", document.body, null, 9, null).singleNodeValue, // grab the #script-nav while checking for the Admin link to be existing
- tmpNav = document.createDocumentFragment(), // create a temporary document fragment
- scriptID = (document.location.href.match(/\/(\d+)/) || ["",""])[1], // grab script ID with RegExp
- extra, i, li;
- // quit if Admin link not found or script ID not found in url
- if(!nav || !scriptID) return;
- // set which links to be added here
- extra = {
- 'Edit Code' : '/scripts/edit_src/',
- 'Edit Metadata' : '/scripts/edit/'
- };
- // loop through the to-be-added-links and add them to the temporary document fragment
- for (i in extra) {
- // create a list element with an anchor node
- li = document.createElement('li');
- li.className = 'menu';
- li.innerHTML = '<a href="'+ extra[i] + scriptID + '" class="admin">' + i + '</a>';
- // add the link to the document fragment
- tmpNav.appendChild(li);
- }
- // add the document fragment to the page
- nav.insertBefore(tmpNav, nav.children[1]);
- })(); // end of anonymous function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement