User:Jdlrobson/global.js: Difference between revisions
Appearance
From Meta, a Wikimedia project coordination wiki
Line 12:
Line 12:
mw.loader.load( 'https://en.wikipedia.org/w/index.php?title=User:Jdlrobson/readingList.js&action=raw&ctype=text/javascript' );
mw.loader.load( 'https://en.wikipedia.org/w/index.php?title=User:Jdlrobson/readingList.js&action=raw&ctype=text/javascript' );
(function () {
const c = document.documentElement.classList;
if ( c.contains( 'skin-night-mode-page-disabled' ) || c.contains( 'skin-theme-clientpref--excluded' ) ) {
c.remove( 'skin-night-mode-page-disabled' );
c.remove( 'skin-theme-clientpref--excluded' );
if ( mw.user.options.values[mw.config.get('skin').replace('-2022','') + '-theme'] === 'day' ) {
c.add( 'skin-theme-clientpref-day' );
} else {
c.add( 'skin-theme-clientpref-night' );
}
const btn = document.createElement('button');
btn.textContent = 'restore day theme';
btn.setAttribute('style', 'position: fixed; bottom: 0; right: 0;' );
document.body.appendChild(btn);
btn.addEventListener('click', () => {
c.add( 'skin-night-mode-page-disabled' );
c.remove( 'skin-theme-clientpref-night' );
} );
}
}());
Latest revision as of 04:04, 20 July 2024
mw.trackSubscribe('resourceloader.exception',function(topic,data){ alert(topic+JSON.stringify(data)); $('body').addClass('user-jdlrobson-error'); }); // setup the global error handler mw.trackSubscribe('global.error',function(topic,error){ alert(JSON.stringify(error));alert(topic); $('body').addClass('user-jdlrobson-error'); }); mw.trackSubscribe('global.error',console.log.bind(console)) mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Jdlrobson/readingList.js&action=raw&ctype=text/javascript');