Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add slur redaction on initial page load #516

Merged
merged 1 commit into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions browser-extension/plugin/src/content-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ function processPage(newUrl) {
}
}, 500);
} else {
mainLoadedChecker = setInterval(() => {
mainLoadedChecker = setInterval(async () => {
console.log('tick');
let body = document.getElementsByTagName('body');
let first_body = body[0];

if (first_body) {
console.log('tick 2');
transformGeneral.processNewlyAddedNodesGeneral(first_body);
await transformGeneral.processNewlyAddedNodesGeneral(first_body);
clearInterval(mainLoadedChecker);
console.log(mainLoadedChecker);
} else {
Expand Down
6 changes: 5 additions & 1 deletion browser-extension/plugin/src/transform-general.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function setCaretPosition(element, offset) {
sel.addRange(range);
}

const processNewlyAddedNodesGeneral = function (firstBody) {
const processNewlyAddedNodesGeneral = async function (firstBody) {
log('processing new nodes');
const config = { attributes: true, childList: true, subtree: true };

Expand All @@ -68,6 +68,10 @@ const processNewlyAddedNodesGeneral = function (firstBody) {
});
}
};

// call on initial page load
await callback();

const observer = new MutationObserver(callback);
observer.observe(firstBody, config);
};
Expand Down