User:Gryllida/js/wab-talk-0.2.js
Note: After saving, you may have to bypass your browser's cache to see the changes. Mozilla / Firefox / Safari: hold down Shift while clicking Reload, or press Ctrl-Shift-R (Cmd-Shift-R on Apple Mac); IE: hold Ctrl while clicking Refresh, or press Ctrl-F5; Konqueror: simply click the Reload button, or press F5; Opera users may need to completely clear their cache in Tools→Preferences. — More skins
$('.mw-headline').each(function( index ) {
// console.log( index + ": " + $( this ).text() );
var txt = $( this ).text();
if(txt.indexOf('Wikinews recent additions') == -1){
return true;
}
var $self = $( this );
// dom
var $span = $('<span class="wab-talk">');
$span.text(' Remove');
$span.attr('style', 'color: blue');
$span_y = $("<span class='wab-talk' style='color:blue'>Yes</span>");
$span_n = $("<span class='wab-talk' style='color:blue'>No</span>");
var $span2 = $("<span class='wab-talk'> Are you sure? </span>");
$span2.append($span_y );
$span2.append($('<span> / </span>') );
$span2.append($span_n );
// event
$span.click(function() { $span2.show(); $(this).hide(); });
$span_n.click(function() { $span2.hide(); $span.show(); });
// // delete the section with number 'index - 1' via api
$span_y.click(function() {
// blank the section
var api = new mw.Api();
api.postWithToken("edit", {
action: 'edit',
title: mw.config.get ('wgPageName'),
section: index+1,
summary: 'blanking section ([[User:Gryllida/js/wab-talk.js|assisted]])',
text: ''
});
// update the view
var $anchor = $self.parent();
$anchor.nextUntil( "h2" ).remove();
$anchor.remove();
$('.wab-talk').remove();
importScript('User:Gryllida/js/wab-talk-0.2.js');
});
// add to h
$span.insertAfter($(this));
$span2.insertAfter($(this));
$span2.hide();
});