ಸದಸ್ಯ:~aanzx/common.js
ಗೋಚರ
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
// For attribution: [[User:DannyS712/EasyResolve]]
// <nowiki>
$(function() {
var EasyResolve = {};
window.EasyResolve = EasyResolve;
EasyResolve.setup = function() {
$('span.mw-editsection-bracket:first-child').each(function() {
if ($(this).parents('#firstHeading')[0]) return;
try {
var sn = $($(this).parent().children()[1]).attr('href').match(/[?&]section=(\d+)/)[1];
this.after(' | ');
$(this).after($('<a class="EasyResolveClose" section=' + sn + '>mark as resolved</a>'));
} catch (e) {
}
});
$('a.EasyResolveClose').click(function() {
$(this).unbind();
$(this).text('marking as resolved...');
EasyResolve.close($(this));
});
};
EasyResolve.close = function(s) {
var sn = s.attr('section');
var pn = mw.config.get('wgPageName');
(new mw.Api()).get({
action: 'query',
titles: pn,
prop: 'revisions',
rvprop: 'content',
rvslots: '*',
rvsection: sn,
format: 'json',
formatversion: 2
}).done(function(response) {
var wt = response.query.pages[0].revisions[0].slots.main.content;
wt += '\n{{section resolved|1=~~~~}}';
(new mw.Api()).postWithToken('csrf', {
action: 'edit',
title: pn,
section: sn,
text: wt,
summary: 'Mark as resolved',
notminor: true,
nocreate: true
}).done(function() {
location.reload();
});
});
};
mw.loader.using('mediawiki.api', function() {
var a = mw.config.get('wgAction'),
ns = mw.config.get('wgNamespaceNumber'),
pn = mw.config.get('wgPageName').replace(/_/g, ' '),
pna = ['ವಿಕಿಪೀಡಿಯ:ಅರಳಿ_ಕಟ್ಟೆ'];
if (a == 'view' && (ns % 2 === 1 || ns === 4 || pna.includes(pn))) {
mw.hook('wikipage.content').add(EasyResolve.setup);
}
});
});
// </nowiki>