User:繁星春水/global.js

$(function{ const PageSelector = ' #content .mw-parser-output '; const ColorList = PageSelector + ' #ColorList '; const CSSTokenSeparators = /[\{\}\:\;\0\s\,]/; var $Loaded = Boolean(window.FDCSSVList_Loaded); var $O = Boolean(window.FDCSSVList_Open); var $S = Boolean(window.FDCSSVList_Side); var $T = Boolean(window.FDCSSVList_Text); var s, c , v , CSSTokens ; if (!$Loaded) { $(PageSelector).first.prepend(

'   \  \  \   \  \  \   '

);  if (!$O) { $(ColorList).toggle }   //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 , title: s+': '+c , text: s+($T?': '+c:'') , css: { display: 'inline-block' , padding: '0.25em' , margin: '0' , overflow: 'wrap' , wordWrap: 'break-word' , width: '10em' , maxWidth: '10em' , minWidth: '10em' , color: 'var(--theme-page-color)' , textShadow: '1px 1px 2px var(--theme-link-color)' } } );      if ( s.includes('-image') || s.includes('-logo') ) {        entry.css( { backgroundColor: 'transparent' , backgroundPosition: 'left top' , backgroundSize: 'contain' , backgroundRepeat: 'no-repeat' , backgroundImage: c       } );      } else if ( s.endsWith( '--rgb' ) ) {       entry.css( 'backgroundColor', 'rgb(' + c + ')' );      } else {       entry.css( 'backgroundColor', c );      }      $(ColorList).append(entry);     } } } } } window.FDCSSVList_Loaded = true; $Loaded = Boolean(window.FDCSSVList_Loaded); }); importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:PageCreator/code2.js',    ]});