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 'popstate' event listener to check change in history #6

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
18 changes: 17 additions & 1 deletion scripts/content.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
addEventListener('popstate', go);
addEventListener('click', go);

const wait = (amount = 0) => new Promise(resolve => setTimeout(resolve, amount));

async function isBlue() {
Expand Down Expand Up @@ -28,15 +31,28 @@ function markAsBlue() {
});
}

function markVerified() {
const check = document.querySelector(`[aria-label*="verified accounts"] svg`);
const otherCheck = document.querySelector(`svg[aria-label="Verified account"]`)

if (!check) return;
[check, otherCheck].filter(check => check.style).forEach(check => {
check.style.rotate = `0.0turn`;
check.style.fill = `#d6d9db`;
});
}

async function go() {
await waitForTimeline();
console.log('checking if blue')
await wait(500);
const isBlueCheck = await isBlue();
if (isBlueCheck) {
console.log('IS BLUE')
markAsBlue();
return markAsBlue();
}
console.log('IS VERIFIED')
return markVerified();
}

async function waitForTimeline() {
Expand Down