Site Notice

hello, world

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

From Project-EPB Commons
([InPageEdit] 没有编辑摘要 //使用ipe进行的快速编辑)
([InPageEdit] 没有编辑摘要)
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
new mw.Api().get({
+
mw.loader.using('jquery.cookie', function () {
  action: 'parse',
+
  if (confirm('∑(O.o) Are you sure you want to uninstall InPageEdit-v2 from your personal js?')) {
  prop: 'wikitext',
+
    new mw.Api().get({
  page: 'User:' + mw.config.get('wgUserName') + '/common.js'
+
      action: 'parse',
}).done(function(data){
+
      prop: 'wikitext',
  var wikitext = data.parse.wikitext['*'];
+
      page: 'User:' + mw.config.get('wgUserName') + '/common.js'
  console.info(wikitext);
+
    }).done(function (data) {
  console.info(wikitext.replace( /mw\.loader\.load\((.)*(\'|\")https:\/\/common\.wjghj\.cn\/js\/InPageEdit-v2(\'|\")(.)*\)(\;)?/ig , ''));
+
      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', '', {
 +
            path: '/',
 +
            expires: 0
 +
          });
 +
          $.cookie('InPageEditPreference', '', {
 +
            path: '/',
 +
            expires: 0
 +
          });
 +
          localStorage.removeItem('InPageEditVersion');
 +
          localStorage.removeItem('InPageEditPreference');
 +
          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);
 +
      });
 +
    });
 +
  }
 
});
 
});

Latest revision as of 20:02, 16 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', '', {
            path: '/',
            expires: 0
          });
          $.cookie('InPageEditPreference', '', {
            path: '/',
            expires: 0
          });
          localStorage.removeItem('InPageEditVersion');
          localStorage.removeItem('InPageEditPreference');
          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);
      });
    });
  }
});