/** * Content script that pulls/queries any necessary information. */ function sendMessage(type, data) { chrome.runtime.sendMessage({ type, data }); } function init() { const urlParams = new URLSearchParams(window.location.search); let id = urlParams.get('id'); if (!id) return; id = id.split('-')[0]; // Check for error const error = document.querySelector('.standard_error'); if (error) return sendMessage('badPage', id); // Scroll page title into view const contentDiv = document.getElementById('content'); if (contentDiv) { contentDiv.scrollIntoView(); window.scrollBy(0, -100); } else return; // Get max entry ID number to search from const topEntry = document.querySelector('#sidebar .blockbody a'); if (topEntry) { const topEntryParams = new URLSearchParams(`?${topEntry.href.split('?')[1]}`); const topEntryID = topEntryParams.get('id').split('-')[0]; sendMessage('topPage', topEntryID); } // Check if AI exists let aiImg = document.querySelector('.metadata img[alt="AI"]'); if (aiImg) { aiImg = aiImg.parentElement.nextElementSibling; const text = aiImg.innerText || aiImg.textContent; if (!/yes/gi.test(text)) sendMessage('badPage', id); } else sendMessage('badPage', id); } init();