From Wikipedia, the free encyclopedia
Content deleted Content added
|
|
|||
| Line 22: | Line 22: | ||
|
if (source === ”) { |
if (source === ”) { |
||
|
link.style.color = “orange”; |
link.style.color = “orange”; |
||
|
link.outerHTML = `< |
link.outerHTML = `<>${link.outerHTML}</>`; |
||
|
continue; |
continue; |
||
|
} |
} |
||
Latest revision as of 14:49, 28 January 2026
function highlightUTM() {
// AI utm_source giveaways
let aiNames = ["chatgpt","openai","gemini","claude","grok"];
// Get all HTML links
let links = document.getElementsByTagName("a");
// Iterate through the links
for (var link of links) {
// Get the HREF of the link
let href = link.getAttribute("href");
// Skip if it doesn't have an HREF
if (!href) continue;
if (href[0] == "#") href = location.href + href;
else if (href[0] == "/") href = location.protocol + "//" + location.pathname;
// Get the utm_source parameter
let source = new URL(href).searchParams.get("utm_source");
if (source !== null) {
// Remove external link icon
link.classList.remove("external");
// Set the title
link.setAttribute("title", source);
// Highlight the link
if (source === '') {
link.style.color = "orange";
link.outerHTML = `<unsetutm>${link.outerHTML}</unsetutm>`;
continue;
}
matched = false;
for (var name of aiNames) {
matched |= source.toLowerCase().includes(name);
}
link.style.color = matched ? "red" : "#ff7800";
// Dot the link
link.style.textDecoration = "underline dotted";
}
}
}
// Override annoying purge dialog
wgAction = mw.config.get('wgAction');
if (wgAction == 'purge') $('form.mw-htmlform').submit();
else highlightUTM();

