Difference between revisions 780809 and 784447 on knwikimw.loader.load('//en.wikipedia.org/w/index.php?title=User:Ucucha/duplinks.js&action=raw&ctype=text/javascript'); mw.loader.load('//en.wikipedia.org/w/index.php?title=User:JeremyMcCracken/contribstab.js&action=raw&ctype=text/javascript'); mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Dipankan001/Edit Count.js&action=raw&ctype=text/javascript'); mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Amalthea/userhighlighter.js&action=raw&ctype=text/javascript'); mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Anomie/ajaxpreview.js&action=raw&ctype=text/javascript'); mw.loader.load('//en.wikipedia.org/w/index.php?title=User:PleaseStand/userinfo.js&action=raw&ctype=text/javascript'); mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Cameltrader/Advisor.js&action=raw&ctype=text/javascript'); mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Kephir/gadgets/sagittarius.js&action=raw&ctype=text/javascript');⏎ ⏎ /* * @name: Rollback * @description: Perform rollbacks without needing to be in the usergroup * @author: Ozank Cx <dev.wikia.com/wiki/User:Ozank_Cx> * Cleanup/+i18n by Count of Howard <dev.wikia.com/wiki/User:Count_of_Howard> */ (function() { if ($('.mw-rollback-link').length) { return; } var config = mw.config.get([ 'wgAction', 'wgPageName', 'wgUserLanguage', 'wgCanonicalSpecialPageName' ]), i18n = { 'en': { title: 'Rollback reverts edit(s) to this page of the last contributor in one click', failGeneral: 'Unable to rollback', failRevisions: 'Failed to get revisions', failContent: 'Failed to get page content', failEditor: 'No different editor found', failPublish: 'Failed to publish edit', success: 'Rollback successful', rollback: 'rollback', summary1: 'Reverted edits by', summary2: 'to last version by', script: 'script', talk: 'talk', block: 'block' }, 'kn': { title: 'ಒಂದು ಕ್ಲಿಕ್ನಲ್ಲಿ ಕೊನೆಯ ಕೊಡುಗೆದಾರರ ಈ ಪುಟಕ್ಕೆ ರೋಲ್ಬ್ಯಾಕ್ ಸಂಪಾದನೆ (ಗಳು) ಹಿಂದಿರುಗಿಸುತ್ತದೆ', failGeneral: 'ರೋಲ್ಬ್ಯಾಕ್ ಮಾಡಲು ಸಾಧ್ಯವಿಲ್ಲ', failRevisions: 'ಪರಿಷ್ಕರಣೆಗಳನ್ನು ಪಡೆಯುವಲ್ಲಿ ವಿಫಲವಾಗಿದೆ', failContent: 'ಪುಟ ವಿಷಯ ಪಡೆಯಲು ವಿಫಲವಾಗಿದೆ', failEditor: 'ಬೇರೆ ಬೇರೆ ಸಂಪಾದಕರೂ ಕಂಡುಬಂದಿಲ್ಲ', failPublish: 'ಸಂಪಾದನೆ ಪ್ರಕಟಿಸಲು ವಿಫಲವಾಗಿದೆ', success: 'ರೋಲ್ಬ್ಯಾಕ್ ಯಶಸ್ವಿ', rollback: 'ರೋಲ್ಬ್ಯಾಕ್, summary1: 'ಹಿಂದಿರುಗಿಸಿದ ಸಂಪಾದನೆಗಳು', summary2: 'ಕೊನೆಯ ಆವೃತ್ತಿಗೆ', script: 'ಸ್ಕ್ರಿಪ್ಟ್', talk: 'ಚರ್ಚೆ', block: 'ಬ್ಲಾಕ್' }, }, lang = i18n[config.wgUserLanguage] || i18n[config.wgUserLanguage.split('-')[0]] || i18n.en; function init() { var rollbackLinkParams = { style: 'cursor: pointer', title: lang.title }; if ( config.wgAction === 'history' && $('#pagehistory li').length > 1 ) { rollbackLinkParams['data-id'] = config.wgPageName; $('#pagehistory li:first .mw-history-undo a').before( $('<span/>', { class: 'mw-custom-rollback-link' }).html( buildElement('a', lang.rollback, rollbackLinkParams) + ' | ' ) ); } else if ( config.wgCanonicalSpecialPageName === 'Contributions' ) { rollbackLinkParams['data-id'] = $('#mw-content-text ul').find('a:first').attr('title'); $('#mw-content-text ul').find('li').each( function() { if ($(this).find('.mw-uctop').length) { $(this).append( $('<span/>', { class: 'mw-custom-rollback-link' }).html( '[' + buildElement('a', lang.rollback, rollbackLinkParams) + ']' ) ); } } ); } else if ( $('#differences-nextlink').length === 0 && ( $.getUrlVar('diff') || $.getUrlVar('oldid') ) ) { rollbackLinkParams['data-id'] = config.wgPageName; $('.mw-usertoollinks:last').after( ' <span class="mw-custom-rollback-link">' + '[' + buildElement('a', lang.rollback, rollbackLinkParams) + ']</span>' ); } $('.mw-custom-rollback-link a').click( function() { getRevisionIdAndContent($(this).attr('data-id'), handleData); $(this).parent().remove(); } ); } function buildElement(tag, html, attrs) { if (typeof(html) !== 'string') { attrs = html; html = null; } var h = '<' + tag; for (var attr in attrs) { if (attrs[attr] === false) { continue; } h += ' ' + attr + '="' + attrs[attr] + '"'; } return h += html ? ">" + html + "</" + tag + ">" : "/>"; } function getRevisionIdAndContent(title, callback) { new mw.Api().get({ action: 'query', prop: 'revisions', titles: title, rvprop: 'user|ids', rvlimit: 500, cb: new Date().getTime() }).done( function(d) { if (!d.error) { callback(title, d); } else { new BannerNotification( lang.failGeneral + ' (' + lang.failRevisions + '): ' + d.error.code, 'error' ).show(); } } ).fail( function() { new BannerNotification( lang.failGeneral + ' (' + lang.failRevisions + ')', 'error' ).show(); } ); } function handleData(title, data) { var revisions; for (var i in data.query.pages) { revisions = data.query.pages[i].revisions; } var currentUser = revisions[0].user, lastUser, revId; for (var i in revisions) { if (revisions[i].user != currentUser) { lastUser = revisions[i].user; revId = revisions[i].revid; break; } } if (lastUser) { new mw.Api().get({ action: 'query', prop: 'revisions', rvprop: 'content', revids: revId, cb: new Date().getTime() }).done( function(d) { if (!d.error) { var content = ""; for (var i in d.query.pages) { if (d.query.pages[i].revisions) { content = d.query.pages[i].revisions[0]["*"]; } } performRollback(title, content, currentUser, lastUser); } else { new BannerNotification( lang.failGeneral + ' (' + lang.failContent + '): ' + d.error.code,'error' ).show(); } } ).fail( function() { new BannerNotification( lang.failGeneral + ' (' + lang.failContent + ')','error' ).show(); } ); } else { new BannerNotification( lang.failGeneral + ' (' + lang.failEditor + ')','error' ).show(); } } function performRollback(page, text, user, user2) { var summary = lang.summary1 + ' [[Special:Contributions/' + user + '|' + user + ']] ([[User_talk:' + user + '|' + lang.talk + ']] | [[Special:Block/' + user + '|' + lang.block + ']]) ' + lang.summary2 + ' [[User:' + user2 + '|' + user2 + ']] (Rollback|' + lang.script + ')'; if (summary.length > 150) { summary = lang.summary1 + ' ' + user + ' (Rollback|' + lang.script + ')'; } new mw.Api().post({ action: 'edit', title: page, text: text, summary: summary, token: mw.user.tokens.values.editToken }).done( function(d) { if (!d.error) { new BannerNotification( lang.success + '!', 'confirm' ).show(); } else { new BannerNotification( lang.failGeneral + ' (' + lang.failPublish + '): ' + d.error.code,'error' ).show(); } } ).fail( function() { new BannerNotification( lang.failGeneral + ' (' + lang.failPublish + ')', 'error' ).show(); } ); } init(); })(); All content in the above text box is licensed under the Creative Commons Attribution-ShareAlike license Version 4 and was originally sourced from https://kn.wikipedia.org/w/index.php?diff=prev&oldid=784447.
![]() ![]() This site is not affiliated with or endorsed in any way by the Wikimedia Foundation or any of its affiliates. In fact, we fucking despise them.
|