fixed cacheing bug

This commit is contained in:
Lalle 2023-05-05 12:48:04 +02:00
parent 8468e225a8
commit 87903aab6b
No known key found for this signature in database
GPG Key ID: A6583D207A8F6B0D

View File

@ -592,17 +592,12 @@ $.queueTask = (() => {
}
})()
$.global = function (fn: Function, data?: any) {
const d = document
if (d) {
const script = $.el('script', {
textContent: `(${fn}).call(document.currentScript.dataset);`,
})
if (data) {
$.extend(script.dataset, data)
}
const target = d.head || d
$.add(target, script)
$.global = function (fn, data) {
if (doc) {
const script = $.el('script',
{ textContent: `(${fn}).call(document.currentScript.dataset);` })
if (data) { $.extend(script.dataset, data) }
$.add((d.head || doc), script)
$.rm(script)
return script.dataset
} else {
@ -672,10 +667,13 @@ $.item = function (key: string, val: string | JSON) {
return item
}
$.oneItemSugar = (fn: (item: any, cb?) => any) => (key: string | any, val?: JSON | string, cb?) => {
const item = typeof key === 'string' ? $.item(key, val) : key
return fn(item, cb)
}
$.oneItemSugar = (fn: Function) => (function (key: string, val: JSON | string, cb) {
if (typeof key === 'string') {
return fn($.item(key, val), cb)
} else {
return fn(key, val)
}
})
$.syncing = dict()
@ -704,12 +702,7 @@ if (platform === 'crx') {
}
})
$.sync = (key: string, cb) => $.syncing[key] = cb
$.forceSync = (key: string, cb) => {
$.syncing[key] = cb
chrome.storage.local.get(key, function (data) {
cb(data[key], key)
})
}
$.forceSync = function () {/* emptey */ }
$.crxWorking = function () {
try {