forked from jae-jae/Userscript-Plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtools.js
More file actions
27 lines (25 loc) · 811 Bytes
/
Copy pathtools.js
File metadata and controls
27 lines (25 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* global parent, Event, sessionStorage */
import timeago from 'timeago.js'
export default {
timeagoFormat (time) {
let lang = (navigator.language === 'zh-CN') ? 'zh_CN' : 'en_short'
return timeago(null, lang).format(time)
},
installUserJs (uri) {
let evt = parent.document.createEvent('MouseEvents')
evt.initEvent('click', true, true)
let link = parent.document.createElement('a')
link.href = uri
// link.click()
link.dispatchEvent(evt)
},
dispatchEvent (eventName) {
parent.document.getElementById('jae_userscript_box').dispatchEvent(new Event(eventName))
},
// 获取油猴缓存好的脚本数据
getData () {
let data = sessionStorage.getItem('jae_fetch_userjs_cache')
data = JSON.parse(data)
return data
}
}