parent
755dbc2909
commit
587625577e
1 changed files with 21 additions and 2 deletions
|
@ -84,6 +84,21 @@ function waitForElement(selector, multiple = false, timeoutDuration = 200000) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the user has logged into the instance.
|
||||||
|
*
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
async function checkLoggedIn() {
|
||||||
|
try {
|
||||||
|
const initialState = await waitForElement("#initial-state", false);
|
||||||
|
return JSON.parse(initialState.textContent).meta.access_token != null;
|
||||||
|
} catch(error) {
|
||||||
|
// cannot fetch login status
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inject replacement onClick handler for Follow button.
|
* Inject replacement onClick handler for Follow button.
|
||||||
*
|
*
|
||||||
|
@ -137,8 +152,12 @@ async function injectInteractionButtons() {
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
function initInjections() {
|
function initInjections() {
|
||||||
injectFollowButton().catch(console.error);
|
checkLoggedIn().then((r) => {
|
||||||
injectInteractionButtons().catch(console.error);
|
if (!r) {
|
||||||
|
injectFollowButton().catch(console.error);
|
||||||
|
injectInteractionButtons().catch(console.error);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue