Jump to content

User:DannyS712 test/dead.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
//<nowiki>
$(function (){
var DBLP_config = {
	name: '[[User:DannyS712/Dead BLP|Dead BLP.js]]',
	version: 1.0,
	debug: true
};
var DBLP_summary = 'SUMMARY with ' + DBLP_config.name + ' (version ' + DBLP_config.version + ')';
var scriptUrl = mw.config.get( 'wgScriptPath' ) + '/api.php';

mw.loader.using( 'mediawiki.util', function () {
  	importScript('User:DannyS712 test/page.js');
    $(document).ready( function () { 
    	mw.util.addPortletLink ( 'p-cactions', 'javascript:void(0)', 'Dead BLP', 'ca-dblp', 'TOOLTIP');
    	$('#ca-dblp').on('click', function() {
        	Mark_dead();
    	} );
    } );
} );
function Mark_dead(){
	var list_page_content = get_page( mw.config.get( 'wgPageName' ) );
	var just_the_table = list_page_content.substring(list_page_content.indexOf("! Biography") + 12, list_page_content.length - 3);
	just_the_table = just_the_table.replace(/_/g, ' ');
	just_the_table = just_the_table.replace(/\[\[/g, 'Talk:');
	just_the_table = just_the_table.replace(/]]/g, '');
//	console.log(just_the_table);
	var as_array = just_the_table.split(/\n*\|-\s+\| \d+\s*\|\s+/);
	as_array.shift();
	for( var i = 0; i < as_array.length-1; i++){ 
		if ( remove(as_array[i])) {
    		as_array.splice(i, 1); 
		}
	}
	console.log(as_array);
}
function remove ( name ){
	if (name === "Talk:June and Jennifer Gibbons") return true;
	if (name === "Talk:Podgórski sisters") return true;
	if (name === "Talk:Bacon Brothers (gangsters)") return true;
	if (name === "Talk:Dionne quintuplets") return true;
	if (name.indexOf("and") > -1) return true;
	if (name.indexOf("&") > -1) return true;
	return false;
}
});
//</nowiki>