User:Ferretwings/common.js

(function {	/**	 * Add a toolbox link to enable/disable my scripts	 *	 * @sources www.mediawiki.org/wiki/Snippets/Toggle_user_scripts	 * @rev 3	 */	var enableMyScripts = $.cookie( 'enable-my-scripts' ) !== 'false';	$(function  { var label = { // Current state <-> Label of toggle button (opposite state) 'true': 'Disable my scripts', 'false': 'Enable my scripts' },			cookieOptions = { expires: 1, path: '/' };

if ( $('#ca-toggle-js').length ) { return; }

$( mw.util.addPortletLink( 'p-tb', '#',			label[ enableMyScripts ], '#ca-toggle-js', 'Turn my scripts on or off and reload the page' ) )			.on( 'click', function (s) {				// Prevent '#' from appearing in address bar				s.preventDefault;				$.cookie( 'enable-my-scripts', !enableMyScripts, cookieOptions );				// Reloads the document (from cache)				document.location.reload( false );			} ); } );

if (!enableMyScripts) { mw.log( 'Note: Your scripts are disabled.' ); return; }

/* Begin user scripts */

// Your scripts here //.ns-1 .mw-body .firstHeading

/* End user scripts */ }); (function { /**	 * Add a toolbox link to enable/disable my css *	 * @sources www.mediawiki.org/wiki/Snippets/Toggle_user_scripts (@rev 3) * guides.codechewing.com/js/disable-enable-stylesheet-javascript */	var enableMyCss = $.cookie( 'enable-my-css' ) !== 'false'; $(function {		var label = {				// Current state <-> Label of toggle button (opposite state)				'true': 'Disable my css',				'false': 'Enable my css'			},			cookieOptions = {				expires: 1,				path: '/'			};

if ( $('#ca-toggle-css').length ) { return; }

$( mw.util.addPortletLink( 'p-tb', '#',			label[ enableMyCss ], '#ca-toggle-css', 'Turn my css on or off and reload the page' ) )			.on( 'click', function (c) {				// Prevent '#' from appearing in address bar				c.preventDefault;				$.cookie( 'enable-my-css', !enableMyCss, cookieOptions );				// Reloads the document (from cache)				document.location.reload( false );			} ); } ); // themeName //var href="/load.php?debug=false&amp;lang=en&amp;modules=user.styles&amp;only=styles&amp;skin=hydra&amp;user=Ferretwings&amp;version=0tllzpz" //function { var stylesheets = document.styleSheets;  var length = stylesheets.length;  var i;

for(i = 0; i < length; i++) { var ss = stylesheet[i]; if (ss.href.search("user.styles") !== -1) {ss.disabled = (!ss.disabled);} } //};

if (!enableMyCss) { mw.log( 'Note: Your css has been disabled.' ); return; }

/* code for enabled css */

// code here //.ns-1 .mw-body .firstHeading

/* End user scripts */ });