Site Notice

hello, world

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

From Project-EPB Commons
([InPageEdit] 没有编辑摘要 //使用ipe进行的快速编辑)
([InPageEdit] 没有编辑摘要 //使用ipe进行的快速编辑)
Line 1: Line 1:
/**** 注意,运行此代码ipe就会从你的个人js被删除,所以不要随便使用…… ****/
+
if (confirm('Are you sure you want to uninstall InPageEdit-v2 from your personal js?')) {
new mw.Api().get({
+
  new mw.Api().get({
  action: 'parse',
+
    action: 'parse',
  prop: 'wikitext',
+
    prop: 'wikitext',
  page: 'User:' + mw.config.get('wgUserName') + '/common.js'
+
    page: 'User:' + mw.config.get('wgUserName') + '/common.js'
}).done(function(data){
+
  }).done(function (data) {
  var wikitext = data.parse.wikitext['*'],
+
    var wikitext = data.parse.wikitext['*'],
      finalText = wikitext.replace( /mw\.loader\.load\((\s)*(\'|\")https:\/\/common\.wjghj\.cn\/js\/InPageEdit-v2(\'|\")(\s)*\)(\;)?/ig , '');
+
    finalText = wikitext.replace(/mw\.loader\.load\((\s)*(\'|\")https:\/\/common\.wjghj\.cn\/js\/InPageEdit-v2(\'|\")(\s)*\)(\;)?/ig, '');
  console.info(wikitext);
+
    console.info('[InPageEdit] Uninstall, submitting...\n' + finalText);
  console.info(finalText);
+
    new mw.Api().post({
  new mw.Api().post({
+
      action: 'edit',
    action: 'edit',
+
      title: 'User:' + mw.config.get('wgUserName') + '/common.js',
    title: 'User:' + mw.config.get('wgUserName') + '/common.js',
+
      text: finalText,
    text: finalText,
+
      summary: 'Uninstall InPageEdit',
    summary: 'Uninstall InPageEdit',
+
      token: mw.user.tokens.get('editToken')
    token: mw.user.tokens.get('editToken')
+
    }).done(function () {
  }).done(function(){console.info('Uninstall InPageEdit - Done')});
+
      console.info('[InPageEdit] Uninstall - Done\nSee you againg.');
});
+
      ssi_modal.dialog('InPageEdit-v2 should be uninstalled from your personal js. Please refresh the page(Ctrl+F5/Command+R)<br>See you again!');
 +
    });
 +
  });
 +
}

Revision as of 01:20, 4 November 2019

if (confirm('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)*\)(\;)?/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\nSee you againg.');
      ssi_modal.dialog('InPageEdit-v2 should be uninstalled from your personal js. Please refresh the page(Ctrl+F5/Command+R)<br>See you again!');
    });
  });
}