do ->
This commit is contained in:
parent
149ea4ccc2
commit
a20d9f7e8b
12
lib/$.coffee
12
lib/$.coffee
@ -53,7 +53,7 @@ $.extend $,
|
|||||||
r.withCredentials = type is 'post'
|
r.withCredentials = type is 'post'
|
||||||
r.send form
|
r.send form
|
||||||
r
|
r
|
||||||
cache: (->
|
cache: do ->
|
||||||
reqs = {}
|
reqs = {}
|
||||||
(url, cb) ->
|
(url, cb) ->
|
||||||
if req = reqs[url]
|
if req = reqs[url]
|
||||||
@ -70,7 +70,6 @@ $.extend $,
|
|||||||
onerror: -> delete reqs[url]
|
onerror: -> delete reqs[url]
|
||||||
req.callbacks = [cb]
|
req.callbacks = [cb]
|
||||||
reqs[url] = req
|
reqs[url] = req
|
||||||
)()
|
|
||||||
cb:
|
cb:
|
||||||
checked: ->
|
checked: ->
|
||||||
$.set @name, @checked
|
$.set @name, @checked
|
||||||
@ -140,7 +139,7 @@ $.extend $,
|
|||||||
root.dispatchEvent new CustomEvent event, {bubbles: true, detail}
|
root.dispatchEvent new CustomEvent event, {bubbles: true, detail}
|
||||||
open: (url) ->
|
open: (url) ->
|
||||||
(GM_openInTab or window.open) url, '_blank'
|
(GM_openInTab or window.open) url, '_blank'
|
||||||
queueTask: (->
|
queueTask: do ->
|
||||||
# inspired by https://www.w3.org/Bugs/Public/show_bug.cgi?id=15007
|
# inspired by https://www.w3.org/Bugs/Public/show_bug.cgi?id=15007
|
||||||
taskQueue = []
|
taskQueue = []
|
||||||
execTask = ->
|
execTask = ->
|
||||||
@ -158,7 +157,6 @@ $.extend $,
|
|||||||
->
|
->
|
||||||
taskQueue.push arguments
|
taskQueue.push arguments
|
||||||
setTimeout execTask, 0
|
setTimeout execTask, 0
|
||||||
)()
|
|
||||||
globalEval: (code) ->
|
globalEval: (code) ->
|
||||||
script = $.el 'script',
|
script = $.el 'script',
|
||||||
textContent: code
|
textContent: code
|
||||||
@ -171,11 +169,10 @@ $.extend $,
|
|||||||
else if unsafeWindow isnt window # Firefox
|
else if unsafeWindow isnt window # Firefox
|
||||||
unsafeWindow
|
unsafeWindow
|
||||||
else # Chrome
|
else # Chrome
|
||||||
(->
|
do ->
|
||||||
p = d.createElement 'p'
|
p = d.createElement 'p'
|
||||||
p.setAttribute 'onclick', 'return window'
|
p.setAttribute 'onclick', 'return window'
|
||||||
p.onclick()
|
p.onclick()
|
||||||
)()
|
|
||||||
bytesToString: (size) ->
|
bytesToString: (size) ->
|
||||||
unit = 0 # Bytes
|
unit = 0 # Bytes
|
||||||
while size >= 1024
|
while size >= 1024
|
||||||
@ -207,7 +204,7 @@ if GM_deleteValue?
|
|||||||
localStorage.setItem name, value
|
localStorage.setItem name, value
|
||||||
GM_setValue name, value
|
GM_setValue name, value
|
||||||
else if window.opera
|
else if window.opera
|
||||||
(->
|
do ->
|
||||||
# http://www.opera.com/docs/userjs/specs/#scriptstorage
|
# http://www.opera.com/docs/userjs/specs/#scriptstorage
|
||||||
# http://www.opera.com/docs/userjs/using/#securepages
|
# http://www.opera.com/docs/userjs/using/#securepages
|
||||||
# >The scriptStorage object is available only during
|
# >The scriptStorage object is available only during
|
||||||
@ -229,7 +226,6 @@ else if window.opera
|
|||||||
# for `storage` events
|
# for `storage` events
|
||||||
localStorage.setItem name, value
|
localStorage.setItem name, value
|
||||||
scriptStorage[name] = value
|
scriptStorage[name] = value
|
||||||
)()
|
|
||||||
else
|
else
|
||||||
$.delete = (name) ->
|
$.delete = (name) ->
|
||||||
localStorage.removeItem g.NAMESPACE + name
|
localStorage.removeItem g.NAMESPACE + name
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
UI = (->
|
UI = do ->
|
||||||
dialog = (id, position, html) ->
|
dialog = (id, position, html) ->
|
||||||
el = d.createElement 'div'
|
el = d.createElement 'div'
|
||||||
el.className = 'dialog'
|
el.className = 'dialog'
|
||||||
@ -349,4 +349,3 @@ UI = (->
|
|||||||
Menu: Menu
|
Menu: Menu
|
||||||
hover: hoverstart
|
hover: hoverstart
|
||||||
}
|
}
|
||||||
)()
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user