Advertisement
thetenfold

Untitled

Jul 9th, 2013
433
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name          USO Admin Menu
  3. // @namespace     erosman
  4. // @description   Adds Admin links to the Script Menu
  5. // @updateURL     https://userscripts.org/scripts/source/172766.meta.js
  6. // @downloadURL   https://userscripts.org/scripts/source/172766.user.js
  7. // @include       http://userscripts.org/scripts/*
  8. // @include       https://userscripts.org/scripts/*
  9. // @include       http://userscripts.org/topics/*
  10. // @include       https://userscripts.org/topics/*
  11. // @grant         none
  12. // @author        erosman
  13. // @version       1.2
  14. // ==/UserScript==
  15.  
  16. /* --------- Note ---------
  17.   This script adds Admin links to the Script Menu
  18.   I have minimised the styling in order to avoid using GM_addStyle
  19.  
  20.   --------- History ---------
  21.  
  22.   1.2 New code + New Style + Added topic pages + More Admin links
  23.   1.1 Fixed the @updateURL & @downloadURL error
  24.   1.0 Initial release
  25.  
  26. */
  27.  
  28.  
  29.  
  30. (function name() { // anonymous function wrapper, used for error checking to end execution
  31. 'use strict';
  32.  
  33. var elements = undefined,
  34.     scriptID = undefined,
  35.     extra = undefined,
  36.     div = undefined,
  37.     i = undefined;
  38.  
  39. if (window.self !== window.top) { return; } // end execution if in a frame
  40.  
  41. elements = document.getElementsByClassName('admin');
  42.  
  43. if (!elements[0] || elements[0].innerHTML !== 'Admin') { return; }  // end execution
  44.  
  45. // get script ID --- this method is 10x faster than elements[0].href.match(/\d+$/) on Firefox
  46. scriptID = elements[0].href.substr(elements[0].href.lastIndexOf('/') + 1);
  47.  
  48. extra = {
  49.   'Edit Metadata' : '/scripts/edit/' ,
  50.   'Edit Code' : '/scripts/edit_src/',
  51.   'Upload New Version' : '/scripts/upload/' ,
  52.   'Screenshots & Icon' : '/scripts/images/' ,
  53. }
  54.  
  55. div = document.createElement('div');
  56. div.setAttribute('style', 'color: #00f;');
  57. div.innerHTML = '<b>Admin:</b>&nbsp;&nbsp; ';
  58.  
  59. for (i in extra) {
  60.   div.innerHTML +=
  61.   '&bull; <a href="'+ extra[i] + scriptID + '" style="text-decoration: none; color: #c00;">' + i + '</a>&nbsp;&nbsp; ';
  62. }
  63.  
  64. document.getElementById('details').appendChild(div);
  65.  
  66. })(); // end of anonymous function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement