mirror of
https://github.com/LalleSX/4chan-XZ.git
synced 2026-01-30 09:48:12 +01:00
fixed cacheing bug
This commit is contained in:
parent
8468e225a8
commit
87903aab6b
@ -592,17 +592,12 @@ $.queueTask = (() => {
|
|||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
|
|
||||||
$.global = function (fn: Function, data?: any) {
|
$.global = function (fn, data) {
|
||||||
const d = document
|
if (doc) {
|
||||||
if (d) {
|
const script = $.el('script',
|
||||||
const script = $.el('script', {
|
{ textContent: `(${fn}).call(document.currentScript.dataset);` })
|
||||||
textContent: `(${fn}).call(document.currentScript.dataset);`,
|
if (data) { $.extend(script.dataset, data) }
|
||||||
})
|
$.add((d.head || doc), script)
|
||||||
if (data) {
|
|
||||||
$.extend(script.dataset, data)
|
|
||||||
}
|
|
||||||
const target = d.head || d
|
|
||||||
$.add(target, script)
|
|
||||||
$.rm(script)
|
$.rm(script)
|
||||||
return script.dataset
|
return script.dataset
|
||||||
} else {
|
} else {
|
||||||
@ -672,10 +667,13 @@ $.item = function (key: string, val: string | JSON) {
|
|||||||
return item
|
return item
|
||||||
}
|
}
|
||||||
|
|
||||||
$.oneItemSugar = (fn: (item: any, cb?) => any) => (key: string | any, val?: JSON | string, cb?) => {
|
$.oneItemSugar = (fn: Function) => (function (key: string, val: JSON | string, cb) {
|
||||||
const item = typeof key === 'string' ? $.item(key, val) : key
|
if (typeof key === 'string') {
|
||||||
return fn(item, cb)
|
return fn($.item(key, val), cb)
|
||||||
}
|
} else {
|
||||||
|
return fn(key, val)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
$.syncing = dict()
|
$.syncing = dict()
|
||||||
|
|
||||||
@ -704,12 +702,7 @@ if (platform === 'crx') {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
$.sync = (key: string, cb) => $.syncing[key] = cb
|
$.sync = (key: string, cb) => $.syncing[key] = cb
|
||||||
$.forceSync = (key: string, cb) => {
|
$.forceSync = function () {/* emptey */ }
|
||||||
$.syncing[key] = cb
|
|
||||||
chrome.storage.local.get(key, function (data) {
|
|
||||||
cb(data[key], key)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
$.crxWorking = function () {
|
$.crxWorking = function () {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user