mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 03:34:40 +00:00
remove document listener for loading which sometimes caused failure to append
This commit is contained in:
+33
-36
@@ -52,49 +52,46 @@ var IsSEQTAPage = false
|
|||||||
|
|
||||||
// This check is placed outside of the document load event due to issues with EP (https://github.com/BetterSEQTA/BetterSEQTA-Plus/issues/84)
|
// This check is placed outside of the document load event due to issues with EP (https://github.com/BetterSEQTA/BetterSEQTA-Plus/issues/84)
|
||||||
const hasSEQTAText = document.childNodes[1].textContent?.includes('Copyright (c) SEQTA Software')
|
const hasSEQTAText = document.childNodes[1].textContent?.includes('Copyright (c) SEQTA Software')
|
||||||
|
init()
|
||||||
|
|
||||||
document.addEventListener(
|
async function init() {
|
||||||
'load',
|
CheckForMenuList()
|
||||||
async function () {
|
const hasSEQTATitle = document.title.includes('SEQTA Learn')
|
||||||
CheckForMenuList()
|
|
||||||
const hasSEQTATitle = document.title.includes('SEQTA Learn')
|
|
||||||
|
|
||||||
if (hasSEQTAText && hasSEQTATitle && !IsSEQTAPage) {
|
if (hasSEQTAText && hasSEQTATitle && !IsSEQTAPage) {
|
||||||
IsSEQTAPage = true
|
IsSEQTAPage = true
|
||||||
console.log('[BetterSEQTA+] Verified SEQTA Page')
|
console.log('[BetterSEQTA+] Verified SEQTA Page')
|
||||||
console.log('[BetterSEQTA+] Injecting CSS')
|
console.log('[BetterSEQTA+] Injecting CSS')
|
||||||
const documentLoadStyle = document.createElement('style')
|
const documentLoadStyle = document.createElement('style')
|
||||||
documentLoadStyle.textContent = documentLoadCSS
|
documentLoadStyle.textContent = documentLoadCSS
|
||||||
document.head.appendChild(documentLoadStyle)
|
document.head.appendChild(documentLoadStyle)
|
||||||
/* console.log(browser.runtime.getURL(documentLoadCSS))
|
/* console.log(browser.runtime.getURL(documentLoadCSS))
|
||||||
console.log(stringToHTML(`<link rel="stylesheet" href="${browser.runtime.getURL(documentLoadCSS)}" />`))
|
console.log(stringToHTML(`<link rel="stylesheet" href="${browser.runtime.getURL(documentLoadCSS)}" />`))
|
||||||
document.head.appendChild(stringToHTML(`<link rel="stylesheet" href="${browser.runtime.getURL(documentLoadCSS)}" />`).firstChild as HTMLLinkElement)
|
document.head.appendChild(stringToHTML(`<link rel="stylesheet" href="${browser.runtime.getURL(documentLoadCSS)}" />`).firstChild as HTMLLinkElement)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
enableCurrentTheme()
|
||||||
|
try {
|
||||||
|
const items = await browser.storage.local.get() as SettingsState
|
||||||
|
|
||||||
enableCurrentTheme()
|
if (items.onoff) {
|
||||||
try {
|
const injectedStyle = document.createElement('style')
|
||||||
const items = await browser.storage.local.get() as SettingsState
|
injectedStyle.textContent = injectedCSS
|
||||||
|
|
||||||
if (items.onoff) {
|
|
||||||
const injectedStyle = document.createElement('style')
|
|
||||||
injectedStyle.textContent = injectedCSS
|
|
||||||
|
|
||||||
document.head.appendChild(injectedStyle)
|
document.head.appendChild(injectedStyle)
|
||||||
//document.head.appendChild(stringToHTML(`<link rel="stylesheet" href="${browser.runtime.getURL(injectedCSS)}" />`).firstChild as HTMLLinkElement)
|
//document.head.appendChild(stringToHTML(`<link rel="stylesheet" href="${browser.runtime.getURL(injectedCSS)}" />`).firstChild as HTMLLinkElement)
|
||||||
}
|
|
||||||
|
|
||||||
main(items)
|
|
||||||
} catch (error: any) {
|
|
||||||
onError(error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
main(items)
|
||||||
|
} catch (error: any) {
|
||||||
|
onError(error)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!hasSEQTAText && !NonSEQTAPage) {
|
if (!hasSEQTAText && !NonSEQTAPage) {
|
||||||
NonSEQTAPage = true
|
NonSEQTAPage = true
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
true,
|
|
||||||
)
|
|
||||||
|
|
||||||
function SetDisplayNone(ElementName: string) {
|
function SetDisplayNone(ElementName: string) {
|
||||||
return `li[data-key=${ElementName}]{display:var(--menuHidden) !important; transition: 1s;}`
|
return `li[data-key=${ElementName}]{display:var(--menuHidden) !important; transition: 1s;}`
|
||||||
|
|||||||
Reference in New Issue
Block a user