Could anyone help me with a function for JavaScript which searches the source code and compares all of the links on the site with the specific link I am looking for.
Use Array.prototype.some
to see if at least one element in document.links
has the href
you're looking for.
var has_link = [].some.call(document.links, function(link) {
return link.href === 'http://www.youtube.com/SPECIFICURL';
});
You can patch it in old browsers using the patch found at MDN Array#some