מדיה ויקי:Gadget-wikibugs-patrol.js
הערה: לאחר הפרסום, ייתכן שיהיה צורך לנקות את זיכרון המטמון (cache) של הדפדפן כדי להבחין בשינויים.
- פיירפוקס / ספארי: להחזיק את המקש Shift בעת לחיצה על טעינה מחדש (Reload), או ללחוץ על צירוף המקשים Ctrl-F5 או Ctrl-R (במחשב מק: ⌘-R).
- גוגל כרום: ללחוץ על צירוף המקשים Ctrl-Shift-R (במחשב מק: ⌘-Shift-R).
- אינטרנט אקספלורר / אדג': להחזיק את המקש Ctrl בעת לחיצה על רענן (Refresh), או ללחוץ על צירוף המקשים Ctrl-F5.
- אופרה: ללחוץ על Ctrl-F5.
if ( mw.config.get('wgPageName') === 'ויקיפדיה:דיווח_על_טעויות' ) { $(function(){ function reloadNotify(msg) { mw.notify(msg).done(function(){ window.location.reload(); }); } function removeSection(section, basetimestamp, starttimestamp, summ) { var api = new mw.Api(), pagename = this.curPage; api.postWithToken('csrf', { action: 'edit', title: 'ויקיפדיה:דיווח על טעויות', summary: summ, minor: 1, basetimestamp: basetimestamp, starttimestamp: starttimestamp, text: '', section: section }).done(function(d) { if (d && d.edit && d.edit.result == 'Success') { reloadNotify('אורכב בהצלחה'); } }); } function archiveToTalk(articleName, sectionTitle, content) { var talkPage = new mw.Title(articleName).getTalkPage(), newContent = content.replace(/== .+? ==\n+/, '').replace(/\{\{\/מצב\|.+?\}\}/, ''); return new mw.Api().post({action: 'edit', minor: 1, title: talkPage.getPrefixedText(), summary: 'העברת דיווח מהדף [[ויקיפדיה:דיווח על טעויות]]', token: mw.user.tokens.get('csrfToken'), section: 'new', sectiontitle: sectionTitle, text: ':דיווח מהדף [[ויקיפדיה:דיווח על טעויות]]\n' + newContent }).then(function(d){ mw.notify($('<a>', {href: talkPage.getUrl(), target: '_blank'}).text('אורכב בהצלחה')); }); } function archiveReport(e) { var summ = prompt('כותרת הדיווח:', 'דיווח שאורכב ב-{{ס:'+'#זמןמ:d xg Y}}'); if(summ === null) return; var articleName = $(this).parents('h2').find('.mw-headline a:first').prop('title').replace(' (הדף אינו קיים)', ''), sectionNum = $(this).parent().find('a').attr('href').match(/section=(.*)/)[1], api = new mw.Api(); api.get( {action:'query',prop:'revisions',titles:mw.config.get('wgPageName'), rvprop:'content|timestamp',rvsection:sectionNum, curtimestamp: 1}).done(function(data){ for(var rv in data.query.pages) { var sectionText = data.query.pages[rv].revisions[0]['*'], basetimestamp = data.query.pages[rv].revisions[0].timestamp; if ((sectionText.indexOf('== [['+articleName+']] ==') !== 0) && (sectionText.indexOf('== [[:'+articleName+']] ==') !== 0)) { reloadNotify('הפסקה אינה קיימת עוד במקומה. מרענן את הדף'); } else { if (sectionText.indexOf('{{#lst:')!=-1) { removeSection(sectionNum, basetimestamp ,data.curtimestamp, '/* '+ articleName +' */ ארכוב'); } else { archiveToTalk(articleName, summ, sectionText).done(function(){removeSection(sectionNum, basetimestamp ,data.curtimestamp, '/* '+ articleName +' */ ארכוב'); }); } } } }); e.preventDefault(); } function removeReport(e) { var summ = prompt('תקציר עריכה למחיקת הדיווח:'); if(summ === null) return; var articleName = $(this).parents('h2').find('.mw-headline a:first').prop('title').replace(' (הדף אינו קיים)', ''), sectionNum = $(this).parent().find('a').attr('href').match(/section=(.*)/)[1], api = new mw.Api(); api.get( {action:'query',prop:'revisions',titles:mw.config.get('wgPageName'), rvprop:'content|timestamp',rvsection:sectionNum, curtimestamp: 1}).done(function(data){ for(var rv in data.query.pages) { var sectionText = data.query.pages[rv].revisions[0]['*'], basetimestamp = data.query.pages[rv].revisions[0].timestamp; if ((sectionText.indexOf('== [['+articleName+']] ==') !== 0) && (sectionText.indexOf('== [[:'+articleName+']] ==') !== 0)) { reloadNotify('הפסקה אינה קיימת עוד במקומה. מרענן את הדף'); } else { removeSection(sectionNum, basetimestamp ,data.curtimestamp, summ); } } }); e.preventDefault(); } $('h2').each(function() { var archive = $('<a>ארכוב</a>').attr({href:'#'}).css({'font-size':'small', 'margin-right':'20px'}).click(archiveReport), removeReportBtn = $('<a>הסרה</a>').attr({href:'#'}).css({'font-size':'small', 'margin-right':'20px'}).click(removeReport); $(this).find('.mw-editsection').append([archive, removeReportBtn]); }); }); }