User:DannyS712 test/dead.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:DannyS712 test/dead. |
//<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>