Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
// ==UserScript== // @name Nested ZSR Navi Menu // @namespace http://cloudmodding.com/ // @version 0.5 // @description A ZSR Navi menu modification that adds nesting for the various header levels. The script also contain a Plus version with additional features that're listed bellow. Disable it by removing the function call in the init function. // @author CloudMax // @match http://zeldaspeedruns.com/* // @match www.zeldaspeedruns.com/* // @copyright 2012+, CloudMax // @require http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js // ==/UserScript== //Changelong//////////////////////////////////////////////////////////////////////////////////////////////////////// //0.5 //The script now run when visiting the website using www //Added a validation so that the script only run if you're in the Games section of ZSR //The Navi Menu can no longer appear in a game sections front page //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //Screenshot Album////////////////////////////////////////////////////////////////////////////////////////////////// // http://imgur.com/a/odWG8 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /* *This script was created for Tampermonkey(Chrome)/Greasemonkey(Firefox) *The nested unordered lists that are generated gets a class applied to them by the name of naviSub<headerNumber> so that each level can be styled. (it is also used for the generating process to find the last suitable list) *By clicking on the yellow triforce symbols you can show/hide nested lists. *A magin/padding trick has been applied to all page content headers (this is normally only applied to h2 headers) so that when you go to a specific anchor, the header will also be displayed. */ //Plus Features///////////////////////////////////////////////////////////////////////////////////////////////////// //Enables the Navi Menu on all pages. You can set the required amount of headers for the Navi Menu to appear. //Changes the Navi Menu title to "Navigation+" to indicate that the plus features are enabled. //The Navi Menu width is dynamic so that it can become slightly wider if the list items doesn't fit. //If a page displays 2 h1 headers at the top of the page, the header with the page name will be removed. //Wraps a link around the game logo in the upper left so that it takes you to the specified games main page. //The Triforce font doesn't have a % symbol, so it is replaced with "Percent" in headers. Ex: "Any%" to "AnyPercent" (DISABLED) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //Settings////////////////////////////////////////////////////////////////////////////////////////////////////////// var defLvl = 2, //All headers with a higher value will be hidden in the Navi Menu by default. nestLimit = 3, //How many header levels the menu will nest. minHeaders = 3, //The amount of headers that must be available for the Navi Menu to appear. (Plus feature) pathSections = location.pathname.replace(/\/+$/, "").split('/'), //Used for page check and when generating links headers = ''; //This variable will store the header selector using for the loop. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //creates the header selector for (var i = 1; i <= nestLimit; i++) { headers += 'h' + i + ','; } headers = headers.slice(0, headers.length - 1); //Removes the last comma var NaviMenu = { init: function () { if ($("li.active > a:contains('Games')").length > 0) { //By checking if the Games dropdown in the navbar is active, we can validate whether or not you're visiting a game page. NaviMenu.activateMenuPlus(); //Enables all the plus features. if ($('#navi').length > 0) { //Make sure that there is a Navi Menu before generating the content. NaviMenu.createLinks(); } } }, createLinks: function () { $('#navi ul').remove(); //Clear the Navi Menu in case one has already been generated. var ul = $('#navi').append('<ul></ul>').find('ul'); $('#pagecontent').children(headers).each(function () { var self = $(this), txt = self.text(), tag = self.prop("tagName").toLowerCase(); if (tag == "h1") { var parent = ul; //The header is a h1, so it will be placed in the root ul } else { /*Old code. This one breaks if the page headers are set up in an odd manner (if the author didn't properly nest the headers, skipping a level.) var parent = ul.find('.naviSub' + parseInt(tag.substring(1)) + ':last'); //It is a sub-header, so it will be placed in the first list with the proper nesting level */ var subLists = ''; for (var i = 1; i <= parseInt(tag.substring(1)); i++) { //Loop through and create a .naviSub selector list for all the values that're lower than the current one subLists += '.naviSub' + i + ','; } subLists = subLists.slice(0, subLists.length - 1); //Removes the last comma var parent = ul.find(subLists).last(); //Use the generated selector to find the last list that has a lower nesting level. } //Create the List Item var li = parent.append('<li><span class="bullet"></span><a href="#' + NaviMenu.slug(txt) + '">' + txt + '</a></li>').find('li:last'); li.append('<ul class="naviSub' + (parseInt(tag.substring(1)) + 1) + '" style="margin-left:10px;list-style-type: none;"></ul>'); //Hides the nested list if the nesting level is higher than the specified default level if (parseInt(tag.substring(1)) + 1 > defLvl) li.find('ul:last').hide() //Generates the anchor ID for the header element $(this).attr("id", NaviMenu.slug(txt)); }); //Remove the main page header in the Navi Menu if it isn't used. if ($('#pagecontent > h1:first').next().prop("tagName").toLowerCase() == "h1") { ul.find('li:first').remove(); } //Remove all the empty lists. ul.find('ul:empty').remove(); //Adds a nested class to all li elements with a list in them so that CSS can be applied to them easily ul.find('ul').parent().addClass('nested'); //Set the Triforce color of list items with a nested menu to yellow, and those without one to SandyBrown. This gives a visual indication that you can toggle an item (the yellow ones) $('li:not(.nested) > .bullet').css('color', 'SandyBrown'); $('.nested > .bullet').css('color', 'Yellow'); //Set the cursor to pointer for the items that can be toggled (the yellow ones) $('.nested > .bullet').css('cursor', 'pointer'); //Applies the padding/margin-top trick to all page content headers so that when you use the navi menu, you'll scroll to the top of the header, instead of bellow it. $('#pagecontent').children(headers).css({ "padding-top": "44px", "margin-top": "-44px" }); //Allows you to toggle nested menues by clicking on the yellow triforce symbols that are displayed. $('#navi span').click(function (e) { $(this).siblings('ul:last').slideToggle(); }); }, slug: function (txt) { //I took this from the original code. Generates a anchor friendly path out of the header text return txt.toLowerCase().replace(/[^\w|\s]/g, '').replace(/[ _]+/g, '-'); }, activateMenuPlus: function () { //Enables the Navi Menu on all pages which normally doesn't have one that has the required amount of headers, except for the game front page. if ($('#navi').length == 0 && $('#pagecontent').children(headers).length >= minHeaders && pathSections.length >= 4) { $('#pagecontent').prepend('<div id="navi" class="navi"/>'); $('#navi').append('<h1> </h1>') .css({ "min-height": "57px", "width": "62px" }); } //Changes the Navi Menu title to "Navigation+". (Indicates that the plus features are enabled) $('#navi h1').text('Navigation+'); //The Navi Menu width is modified so that it can become slightly wider if the list items doesn't fit. $('#navi').css({ "min-width": "230px", "max-width": "300px", "width": "auto" }); //If a page displays 2 h1 headers at the top of the page, the header with the page name will be removed. if ($('#pagecontent > h1:first').next().prop("tagName").toLowerCase() == "h1") { $('#pagecontent > h1:first').remove(); } //Wraps a link around the game logo in the upper left that takes you to the specified games main game. $(".game-logo > img").wrap('<a href="/' + pathSections[1] + '" />'); //Replaces the "%" symbol in all h1 headers with "Percent" as the Triforce font doesn't have a % symbol. /* $("h1").each(function () { $(this).text($(this).text().replace('%', 'Percent')); }); */ } }; NaviMenu.init();
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
Trading method
CSS | 3 min ago | 0.32 KB
Google Docs - Exploit
18 min ago | 0.32 KB
Earn money on Changelly
CSS | 32 min ago | 0.32 KB
SwapEngine Bug [build 1.3]
46 min ago | 0.32 KB
December smells like money
CSS | 1 hour ago | 0.32 KB
SelectionEdit.pas
Delphi | 8 hours ago | 27.66 KB
SelectionEdit.h
C++ | 8 hours ago | 1.42 KB
SelectionEdit.cpp
C++ | 8 hours ago | 17.22 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!