User:Proteins/stripanchors.js

// // Strip document hyperlinks (esp. wikilinks), leaving only their text; useful for FireVox screen reader

function stripHyperlinks { var alert_string; var temp_hyperlink; var temp_hyperlink_text;

var num_hyperlinks; var hyperlink_index = 0; var hyperlink_counter = 0; var num_hyperlinks_removed = 0;

var parent_node; var replacement_node;

num_hyperlinks = document.links.length; alert_string = "This document has " + num_hyperlinks + " candidate hyperlinks:\n"; while (num_hyperlinks_removed<num_hyperlinks && num_hyperlinks_removed<40) { temp_hyperlink = document.links[hyperlink_index]; hyperlink_counter++; if (temp_hyperlink.className == "image") { hyperlink_index++; continue; } parent_node = temp_hyperlink.parentNode; temp_hyperlink_text = document.createTextNode(temp_hyperlink.innerHTML); alert_string += "Removed link " + hyperlink_counter + "/" + num_hyperlinks + ": " + temp_hyperlink.title + "(" + temp_hyperlink.innerHTML + ")\n"; parent_node.replaceChild(temp_hyperlink_text, temp_hyperlink); num_hyperlinks_removed++; }	document.normalize; window.alert(alert_string); }

$(function {            mw.util.addPortletLink('p-cactions', 'javascript:stripHyperlinks', 'Strip links', 'ca-nolinks', 'Strips hyperlinks', , ); });

//