User:Technical 13/SandBox/DeOrphaner.js

var isBeta = false; var strGadgetName = 'DeOrphaner'; if ( isBeta ) { var isUsingGadget = mw.user.options.get( 'gadget-' + strGadgetName ); function setGadget( useGadget = ( mw.user.options.get( 'gadget-' + strGadgetName ) == undefined ? true : false ) ) { var strNotify, strChange; if ( useGadget ) { strChange = 'gadget-' + strGadgetName + '=1'; strNotify = ' The gadget has been successfully enabled. ';     }      else { strChange = 'gadget-' + strGadgetName + '=0'; strNotify = ' The gadget has been successfully disabled, click undo or visit your gadgets to re-enable it. ';     }      ( new mw.Api ).postWithToken( 'options', {        action: 'options',        change: strChange      } ).done( function ( data ) {        if ( data.warnings == undefined ) {          mw.notify( $( strNotify ), { title: strGadgetName + ( useGadget ? ' enabled' : ' disabled' ) + '!', autoHide: false } );        }        else {          strNotify = ' Unable to ' + ( useGadget ? 'enable' : 'disable' ) + ' gadget: ';         strNotify += '' + data.warnings.options[ '*' ] + ' ';          mw.notify( $( strNotify ), { title: strGadgetName + ' toggle failed!', autoHide: false } );        }      } ); }   async function getUserSkinJSContent { return await ( new mw.Api ).get( {       action: 'query',        titles: 'User:' + mw.config.get( 'wgUserName' ) + '/' + mw.user.options.get( 'skin' ) + '.js',        prop: 'revisions',        rvprop: 'content',        indexpageids: true      } ).done( function( data ) {        var qry = data.query;        return qry.pages[ qry.pageids[ 0 ] ].revisions[ 0 ][ "*" ];      } ); }   var qryUseBeta = ( isUsingGadget ? confirm( 'This userscript has been turned into a Gadget,\n\tPress [OK] to switch to the gadget or [Cancel] to use the beta script.' ) : false ); if ( qryUseBeta ) { setGadget( true ); /*     ( new mw.Api ).postWithToken( 'edit', {        action: 'edit',        title: 'User:' + mw.config.get( 'wgUserName' ) + '/' + mw.user.options.get( 'skin' ) + '.js',        summary: 'Commenting out use of ' +  + ' beta script.',        minor: true,        bot: true,        nocreate: true,        text: await getUserSkinJSContent.replace( /((?:importScript|mw\.loader\.load)\( *['"](?:(?:http:)?\/\/ddowiki\.com\/index\.php\?title=)U(?:ser):Technical_13\/SandBox\/DeOrphaner.js(?:&action=raw&ctype=text\/javascript)?["'] *\))/gi, '//$1' )      } ).done( function( data ) {      } );//*/ }   else { setGadget( false ); } }