Site Notice

hello, world

Difference between revisions of "MediaWiki:Js-InPageEdit-v2.js/uninstall.js"

From Project-EPB Commons
Line 1: Line 1:
if (confirm('∑(O.o) Are you sure you want to uninstall InPageEdit-v2 from your personal js?')) {
+
mw.loader.using('jquery.cookie', function () {
  new mw.Api().get({
+
  if (confirm('∑(O.o) Are you sure you want to uninstall InPageEdit-v2 from your personal js?')) {
    action: 'parse',
+
    new mw.Api().get({
    prop: 'wikitext',
+
      action: 'parse',
    page: 'User:' + mw.config.get('wgUserName') + '/common.js'
+
      prop: 'wikitext',
  }).done(function (data) {
+
      page: 'User:' + mw.config.get('wgUserName') + '/common.js'
    var wikitext = data.parse.wikitext['*'],
+
    }).done(function (data) {
    finalText = wikitext.replace(/mw\.loader\.load\((\s)*(\'|\")https:\/\/common\.wjghj\.cn\/js\/InPageEdit-v2(\'|\")(\s)*\)(\;)?(\n)?/ig, '');
+
      var wikitext = data.parse.wikitext['*'],
    console.info('[InPageEdit] Uninstall - Submitting...\n' + finalText);
+
      finalText = wikitext.replace(/mw\.loader\.load\((\s)*(\'|\")https:\/\/common\.wjghj\.cn\/js\/InPageEdit-v2(\'|\")(\s)*\)(\;)?(\n)?/ig, '');
    new mw.Api().post({
+
      console.info('[InPageEdit] Uninstall - Submitting...\n' + finalText);
      action: 'edit',
+
      new mw.Api().post({
      title: 'User:' + mw.config.get('wgUserName') + '/common.js',
+
        action: 'edit',
      text: finalText,
+
        title: 'User:' + mw.config.get('wgUserName') + '/common.js',
      summary: 'Uninstall InPageEdit',
+
        text: finalText,
      token: mw.user.tokens.get('editToken')
+
        summary: 'Uninstall InPageEdit',
    }).done(function () {
+
        token: mw.user.tokens.get('editToken')
      console.info('[InPageEdit] Uninstall - Done\nWanna see you againg.');
+
      }).done(function () {
      if (confirm('Erase your InPageEdit personnal settings?')) {
+
        console.info('[InPageEdit] Uninstall - Done\nWanna see you againg.');
        mw.loader.using('jquery.cookie',function(){
+
        if (confirm('Erase your InPageEdit personnal settings?')) {
           $.cookie('InPageEditVersion','',{expires:0});
+
           $.cookie('InPageEditVersion', '', {
           $.cookie('InPageEditPreference','',{expires:0});
+
            expires: 0
 +
          });
 +
           $.cookie('InPageEditPreference', '', {
 +
            expires: 0
 +
          });
 
           console.info('[InPageEdit] Erase personnal settings - Done');
 
           console.info('[InPageEdit] Erase personnal settings - Done');
        });
+
          alert(' \\(QwQ) \nInPageEdit-v2 should be uninstalled from your personal js.\nBye bye, wanna see you again!');
      }
+
          window.location.reload(true);
      alert(' \\(QwQ) \nInPageEdit-v2 should be uninstalled from your personal js.\nBye bye, wanna see you again!');
+
        } else {
      window.location.reload(true);
+
          alert(' \\(QwQ) \nInPageEdit-v2 should be uninstalled from your personal js.\nBye bye, wanna see you again!');
 +
          window.location.reload(true);
 +
        }
 +
      });
 
     });
 
     });
   });
+
   }
}
+
});

Revision as of 01:10, 5 November 2019

mw.loader.using('jquery.cookie', function () {
  if (confirm('∑(O.o) Are you sure you want to uninstall InPageEdit-v2 from your personal js?')) {
    new mw.Api().get({
      action: 'parse',
      prop: 'wikitext',
      page: 'User:' + mw.config.get('wgUserName') + '/common.js'
    }).done(function (data) {
      var wikitext = data.parse.wikitext['*'],
      finalText = wikitext.replace(/mw\.loader\.load\((\s)*(\'|\")https:\/\/common\.wjghj\.cn\/js\/InPageEdit-v2(\'|\")(\s)*\)(\;)?(\n)?/ig, '');
      console.info('[InPageEdit] Uninstall - Submitting...\n' + finalText);
      new mw.Api().post({
        action: 'edit',
        title: 'User:' + mw.config.get('wgUserName') + '/common.js',
        text: finalText,
        summary: 'Uninstall InPageEdit',
        token: mw.user.tokens.get('editToken')
      }).done(function () {
        console.info('[InPageEdit] Uninstall - Done\nWanna see you againg.');
        if (confirm('Erase your InPageEdit personnal settings?')) {
          $.cookie('InPageEditVersion', '', {
            expires: 0
          });
          $.cookie('InPageEditPreference', '', {
            expires: 0
          });
          console.info('[InPageEdit] Erase personnal settings - Done');
          alert(' \\(QwQ) \nInPageEdit-v2 should be uninstalled from your personal js.\nBye bye, wanna see you again!');
          window.location.reload(true);
        } else {
          alert(' \\(QwQ) \nInPageEdit-v2 should be uninstalled from your personal js.\nBye bye, wanna see you again!');
          window.location.reload(true);
        }
      });
    });
  }
});