// ==UserScript== // @name trick link detector // @version 1.1 // @namespace reddit_listen2 // @description Based on a Chrome plugin by /u/filipekiss // @include http* // ==/UserScript== urlRegex = /^http(?:s?):\/\/.+/i String.prototype.unescapeHtml = function () { var temp = document.createElement("div"); temp.innerHTML = this; var result = temp.childNodes[0].nodeValue; temp.removeChild(temp.firstChild); return result; } var as = document.getElementsByTagName("a"); for (var i = 0; i < as.length; i++) { if (as[i].innerHTML.match(urlRegex) && as[i].innerHTML != as[i].href) { //now we have a potential match. redo the check with all unescaped characters to be sure if (as[i].innerHTML.unescapeHtml() !== as[i].href.unescapeHtml()) { var warning = document.createElement("span"); warning.style.display = "inline-block"; warning.style.padding = "2px"; warning.style.backgroundColor = "#F00"; warning.style.color = "#FFF"; warning.style.border = "1px solid #760A00"; warning.style.borderRadius = "2px"; warning.style.margin = "0px 3px"; warning.style.fontSize = "x-small"; warning.innerHTML = "!!"; as[i].parentNode.insertBefore(warning, as[i].nextSibling); } } }