address comments
This commit is contained in:
parent
3c6d43b598
commit
a594e53d71
3 changed files with 20 additions and 18 deletions
|
@ -24,6 +24,9 @@
|
||||||
"allowTemplateLiterals": false
|
"allowTemplateLiterals": false
|
||||||
}],
|
}],
|
||||||
"brace-style": 2,
|
"brace-style": 2,
|
||||||
|
"keyword-spacing": ["error", {
|
||||||
|
"after": true
|
||||||
|
}],
|
||||||
|
|
||||||
// just to make sure (are defaults)
|
// just to make sure (are defaults)
|
||||||
"indent": ["error", 4],
|
"indent": ["error", 4],
|
||||||
|
|
|
@ -154,7 +154,7 @@ function getInteractionType(url) {
|
||||||
async function onTabUpdate(tabId, changeInfo) {
|
async function onTabUpdate(tabId, changeInfo) {
|
||||||
const ownMastodon = await AddonSettings.get("ownMastodon");
|
const ownMastodon = await AddonSettings.get("ownMastodon");
|
||||||
const currentURL = new URL(changeInfo.url);
|
const currentURL = new URL(changeInfo.url);
|
||||||
if(ownMastodon.server !== currentURL.hostname){
|
if (ownMastodon.server !== currentURL.hostname){
|
||||||
browser.tabs.executeScript({
|
browser.tabs.executeScript({
|
||||||
file: "/content_script/mastodonInject.js"
|
file: "/content_script/mastodonInject.js"
|
||||||
});
|
});
|
||||||
|
|
|
@ -39,7 +39,7 @@ function onClickInteract(event) {
|
||||||
* Wait for element to appear.
|
* Wait for element to appear.
|
||||||
*
|
*
|
||||||
* @param {string} selector
|
* @param {string} selector
|
||||||
* @param {boolean} multiple
|
* @param {boolean} [multiple=false]
|
||||||
* @param {number} timeoutDuration
|
* @param {number} timeoutDuration
|
||||||
* @see {@link https://github.com/storybookjs/test-runner/blob/6d41927154e8dd1e4c9e7493122e24e2739a7a0f/src/setup-page.ts#L134}
|
* @see {@link https://github.com/storybookjs/test-runner/blob/6d41927154e8dd1e4c9e7493122e24e2739a7a0f/src/setup-page.ts#L134}
|
||||||
* from which this was adapted
|
* from which this was adapted
|
||||||
|
@ -59,14 +59,14 @@ function waitForElement(selector, multiple = false, timeoutDuration) {
|
||||||
}, timeoutDuration);
|
}, timeoutDuration);
|
||||||
|
|
||||||
const element = getElement();
|
const element = getElement();
|
||||||
if(isElementFound(element)){
|
if (isElementFound(element)){
|
||||||
window.clearTimeout(timeout);
|
window.clearTimeout(timeout);
|
||||||
return resolve(element);
|
return resolve(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
const observer = new MutationObserver(() => {
|
const observer = new MutationObserver(() => {
|
||||||
const element = getElement();
|
const element = getElement();
|
||||||
if(isElementFound(element)){
|
if (isElementFound(element)){
|
||||||
window.clearTimeout(timeout);
|
window.clearTimeout(timeout);
|
||||||
resolve(element);
|
resolve(element);
|
||||||
observer.disconnect();
|
observer.disconnect();
|
||||||
|
@ -103,23 +103,22 @@ async function injectFollowButton() {
|
||||||
*/
|
*/
|
||||||
async function injectInteractionButtons() {
|
async function injectInteractionButtons() {
|
||||||
const INJECTED_REPLY_CLASS = "mastodon-simplified-federation-injected-interaction";
|
const INJECTED_REPLY_CLASS = "mastodon-simplified-federation-injected-interaction";
|
||||||
try {
|
const replyButtons = await waitForElement(
|
||||||
const replyButtons = await waitForElement(
|
".item-list[role='feed'] article[data-id] .status__action-bar button," +
|
||||||
".item-list[role='feed'] article[data-id] .status__action-bar button," +
|
".detailed-status__wrapper .detailed-status__action-bar button",
|
||||||
".detailed-status__wrapper .detailed-status__action-bar button",
|
true,
|
||||||
true,
|
TIMEOUT_DURATION,
|
||||||
TIMEOUT_DURATION,
|
);
|
||||||
);
|
replyButtons.forEach((button) => {
|
||||||
replyButtons.forEach((button) => {
|
try {
|
||||||
if(!button.classList.contains(INJECTED_REPLY_CLASS)){
|
if (!button.classList.contains(INJECTED_REPLY_CLASS)){
|
||||||
button.addEventListener("click", onClickInteract);
|
button.addEventListener("click", onClickInteract);
|
||||||
button.classList.add(INJECTED_REPLY_CLASS);
|
button.classList.add(INJECTED_REPLY_CLASS);
|
||||||
}
|
}
|
||||||
});
|
} catch (error) {
|
||||||
} catch (error) {
|
// Interaction buttons failed to appear
|
||||||
// Interaction buttons failed to appear
|
}
|
||||||
console.log(error);
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue