User:DSquirrelGM/global.js

$('.mw-highlight').removeClass('mw-highlight'); if (mw.config.get('wgAction') === 'delete') { $('#wpReason').removeAttr('value'); }

//mw.loader.load( 'https://dev.fandom.com/wiki/MediaWiki:FD-CSS-VList.js?action=raw&ctype=text/javascript' );

( function {

var _Show, _Mini , _Side , _Values ;

window.FDCSSVList_Show = 1; window.FDCSSVList_Mini = 1;

try { _Show = window.FDCSSVList_Show.toString; } catch(e) { _Show = false; }

try { _Mini = window.FDCSSVList_Mini.toString; } catch(e) { _Mini = false; }

try { _Side = window.FDCSSVList_Side.toString; } catch(e) { _Side = true; }

try { _Values = window.FDCSSVList_Values.toString; } catch(e) { _Values = false; }

const PageSelector = ' #content .mw-parser-output '; const ColorList = PageSelector + ' #ColorList ';

if ( $( ColorList ).length > 0 ) { return; }

const CSSTokenSeparators = /[\{\}\:\;\0\s\,]/; var s, c , v , CSSTokens ;

var Image_ColorSwatch = '   ' ;

var Image_PencilAlt = '    ' ;

$( PageSelector ).prepend( '' + 's' + _Show + ' m'+ _Mini + ' y' + _Side + ' v' + _Values + Image_ColorSwatch + '' + Image_PencilAlt + ' ' );

//style setting iteration / filters //assumes CSS variable setting intent based on name: //--*-image: background image url //--*--rgb: color value triplet for rgb / rgba //--*: any other variable assumed to represent color

var styleSheets = Array.from( document.styleSheets ).map( function( styleSheet ) { try { return Array.from(styleSheet.cssRules); } catch(e) { return []; } } );

for ( i = 0 ; i < styleSheets.length ; i++ ) {

for ( r = 0 ; r < styleSheets[i].length ; r++ ) {

v = styleSheets[i][r].cssText;

CSSTokens = v.split(CSSTokenSeparators);

for ( d = 0 ; d < CSSTokens.length ; d++ ) {

s = CSSTokens[d];

if ( s.startsWith( '--' ) && $( '#CSSVL' + s ).length === 0 ) {

c = styleSheets[i][r].style.getPropertyValue(s);

var entry = $( ' ', { id: 'CSSVL' + s , css: { padding: '0.125em' , margin: '0.125em' , textShadow: '1px 1px 0 var(--theme-link-color)' } } ).append( $(' ' , { text: s + ':' } ) , ' ', $( ' ' , { text: c } ) );

if (s.includes('-image') || s.includes('-logo')) {

entry.css( { backgroundColor: 'transparent', backgroundPosition: 'left top' , backgroundSize: 'contain' , backgroundRepeat: 'no-repeat' , overflow: 'wrap' , wordWrap: 'break-word' , backgroundImage: c } )

} else if ( s.endsWith( '--rgb' ) ) {

entry.css( 'backgroundColor', 'rgb(' + c + ')' )

} else {

entry.css('backgroundColor', c)

}

$(ColorList).append(entry);

}

}

}

}

} );