User:David Eppstein/HarvErrors.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.
// Copied from User:Ucucha/HarvErrors.js
// and modified to disable the "no link pointing to this" error
if(window.checkLinksToCitations === undefined)
    window.checkLinksToCitations = true;

jQuery(document).ready(function($) {
    links = document.links;
    for (i=0; i < links.length; i++)
    {
        href = links[i].getAttribute('href');
        if (href.indexOf('#CITEREF') == 0)
            if (document.getElementById(href.substring(1)) == null)
                links[i].parentNode.innerHTML +=
                    " <strong class=error>Harv error: link from " +
                    href +
                    " doesn't point to any citation.</strong>";
    }
});