mirror of
https://github.com/LalleSX/4chan-XZ.git
synced 2025-10-07 07:22:37 +02:00
fixed cacheing bug
This commit is contained in:
parent
8468e225a8
commit
87903aab6b
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user