mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 03:34:40 +00:00
clean up customshortcuts function
This commit is contained in:
+4
-8
@@ -2196,6 +2196,7 @@ async function GetLessonColours() {
|
|||||||
|
|
||||||
export function CreateCustomShortcutDiv(element: any) {
|
export function CreateCustomShortcutDiv(element: any) {
|
||||||
// Creates the stucture and element information for each seperate shortcut
|
// Creates the stucture and element information for each seperate shortcut
|
||||||
|
console.log(`[BetterSEQTA+] Adding shortcut: ${element.name}`)
|
||||||
var shortcut = document.createElement('a')
|
var shortcut = document.createElement('a')
|
||||||
shortcut.setAttribute('href', element.url)
|
shortcut.setAttribute('href', element.url)
|
||||||
shortcut.setAttribute('target', '_blank')
|
shortcut.setAttribute('target', '_blank')
|
||||||
@@ -2252,22 +2253,17 @@ export function RemoveShortcutDiv(elements: any) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function AddCustomShortcutsToPage() {
|
async function AddCustomShortcutsToPage() {
|
||||||
const result = browser.storage.local.get(['customshortcuts'])
|
const result = await browser.storage.local.get(['customshortcuts'])
|
||||||
function open (result: any) {
|
|
||||||
|
|
||||||
var customshortcuts: any = Object.values(result)[0]
|
let customshortcuts: any = Object.values(result)[0]
|
||||||
if (customshortcuts.length > 0) {
|
if (customshortcuts.length > 0) {
|
||||||
(document.getElementsByClassName('shortcut-container')[0] as HTMLElement).style.display =
|
|
||||||
'block'
|
|
||||||
for (let i = 0; i < customshortcuts.length; i++) {
|
for (let i = 0; i < customshortcuts.length; i++) {
|
||||||
const element = customshortcuts[i]
|
const element = customshortcuts[i]
|
||||||
CreateCustomShortcutDiv(element)
|
CreateCustomShortcutDiv(element)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result.then(open, onError)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadHomePage() {
|
async function loadHomePage() {
|
||||||
// Sends the html data for the home page
|
// Sends the html data for the home page
|
||||||
|
|||||||
Reference in New Issue
Block a user