Thành viên:NgocAnMaster/HarvErrors.js
Chú ý: Sau khi lưu thay đổi trang, bạn phải xóa bộ nhớ đệm của trình duyệt để nhìn thấy các thay đổi. Google Chrome, Firefox, Internet Explorer và Safari: Giữ phím ⇧ Shift và nhấn nút Reload/Tải lại trên thanh công cụ của trình duyệt. Để biết chi tiết và hướng dẫn cho các trình duyệt khác, xem Trợ giúp:Xóa bộ nhớ đệm.
// Usage: add importScript(User:NgocAnMaster/HarvErrors.js); to Special:Mypage/skin.js
// See also Wikipedia:Centralized discussion/Citation discussion#Technical discussion regarding Harvard Refs
// This script works fine for Harvard references in <ref> tags, but for inline Harv. refs,
// the error message shows up at the end of the paragraph in which the error is
jQuery(document).ready(function($) {
const error = " <strong class=error>Lỗi Harv: liên kết này không trỏ tới bất kỳ chú thích nào.</strong>";
const links = document.links;
for (let i = 0; i < links.length; i++) {
const href = links[i].getAttribute('href');
if (href.indexOf('#CITEREF') == 0 && document.getElementById(href.substring(1)) == null) {
links[i].parentNode.innerHTML += error;
}
}
});