intermediate

This commit is contained in:
Fabian Freund
2024-12-12 09:44:33 +01:00
parent 0710116feb
commit 6b2ae28828
108 changed files with 5531 additions and 2265 deletions
@@ -0,0 +1,47 @@
const port = browser.runtime.connectNative("mozacReaderExtract");
let domChanged = false;
let lastContent = '';
function parseContent() {
const article = window.parseReaderable(document);
if (article && lastContent !== article.textContent) {
port.postMessage(article);
lastContent = article.textContent;
}
domChanged = false;
}
port.onMessage.addListener((message) => {
if (message.action === "parseContent") {
if (domChanged) {
parseContent();
}
}
});
const observer = new MutationObserver(() => {
domChanged = true;
});
const observerConfig = {
childList: true,
subtree: true,
characterData: true,
attributes: false
};
// Wait for page to be fully loaded
if (document.readyState === 'complete') {
parseContent();
observer.observe(document.body, observerConfig);
} else {
window.addEventListener('load', parseContent);
}
window.addEventListener('unload', () => {
observer.disconnect();
});
@@ -0,0 +1,29 @@
{
"manifest_version": 2,
"browser_specific_settings": {
"gecko": {
"id": "readability-extract@movenext.me"
}
},
"name": "Extract text of Websites",
"version": "1.0",
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": [
"readability.min.js",
"content.js"
]
}
],
"permissions": [
"mozillaAddons",
"geckoViewAddons",
"nativeMessaging",
"nativeMessagingFromContent",
"storage",
"tabs",
"webNavigation",
"<all_urls>"
]
}
@@ -0,0 +1 @@
../../../../../../javascript/readability/dist/readability.min.js