File tree Expand file tree Collapse file tree 7 files changed +59
-16
lines changed
Expand file tree Collapse file tree 7 files changed +59
-16
lines changed Original file line number Diff line number Diff line change 1717// @exclude http://www.dev/Show-Site-All-UserJS/ui.html
1818// @require https://greasyfork.org/scripts/23419-l-js/code/ljs.js
1919// @require https://greasyfork.org/scripts/23420-userjs-base-js/code/userjs-basejs.js
20- // @resource ui https://raw.githubusercontent.com/jae-jae/Show-Site-All-UserJS/master/dist/ui.html?_=1519625029415
21- // @resource uiJs https://raw.githubusercontent.com/jae-jae/Show-Site-All-UserJS/master/dist/ui.js?_=1519625029415
20+ // @resource ui https://raw.githubusercontent.com/jae-jae/Show-Site-All-UserJS/master/dist/ui.html?_=1520937486364
21+ // @resource uiJs https://raw.githubusercontent.com/jae-jae/Show-Site-All-UserJS/master/dist/ui.js?_=1520937486364
22+ // @resource count https://greasyfork.org/scripts/by-site.json
2223// @grant GM_xmlhttpRequest
2324// @grant GM_getResourceText
2425// @grant GM_getValue
Original file line number Diff line number Diff line change 1717// @exclude http://www.dev/Show-Site-All-UserJS/ui.html
1818// @require https://raw.githubusercontent.com/jae-jae/l.js/master/userjs/l.userjs.min.js
1919// @require https://gist.githubusercontent.com/jae-jae/35a1833079d26e6c9d9c6d5bed982353/raw/userjs-base.js
20- // @resource ui https://raw.githubusercontent.com/jae-jae/Show-Site-All-UserJS/master/dist/ui.html?_=1519625029412
21- // @resource uiJs https://raw.githubusercontent.com/jae-jae/Show-Site-All-UserJS/master/dist/ui.js?_=1519625029412
20+ // @resource ui https://raw.githubusercontent.com/jae-jae/Show-Site-All-UserJS/master/dist/ui.html?_=1520937486364
21+ // @resource uiJs https://raw.githubusercontent.com/jae-jae/Show-Site-All-UserJS/master/dist/ui.js?_=1520937486364
22+ // @resource count https://greasyfork.org/scripts/by-site.json
2223// @grant GM_xmlhttpRequest
2324// @grant GM_getResourceText
2425// @grant GM_getValue
Original file line number Diff line number Diff line change @@ -17,11 +17,23 @@ export default {
1717 } ,
1818 dispatchEvent ( eventName ) {
1919 parent . document . getElementById ( 'jae_userscript_box' ) . dispatchEvent ( new Event ( eventName ) )
20+ } ,
21+ sleep ( ms ) {
22+ return new Promise ( resolve => setTimeout ( resolve , ms ) )
2023 } ,
2124 // 获取油猴缓存好的脚本数据
2225 getData ( ) {
26+ this . dispatchEvent ( 'fetchData' )
2327 let data = sessionStorage . getItem ( 'jae_fetch_userjs_cache' )
28+ while ( ! data ) {
29+ data = sessionStorage . getItem ( 'jae_fetch_userjs_cache' )
30+ await this . sleep ( 1000 )
31+ }
2432 data = JSON . parse ( data )
2533 return data
34+ } ,
35+
36+ getCount ( ) {
37+ return 12
2638 }
2739}
Original file line number Diff line number Diff line change 106106 components: { Info, Indicator },
107107 mounted : function () {
108108 // let host = location.host.split('.').splice(-2).join('.');
109- /* let host = 'baidu.com'
109+ /** let host = 'baidu.com'
110110 fetch(`https://greasyfork.org/zh-CN/scripts/by-site/${host}.json`)
111111 .then((r) => {
112112 r.json().then((json) => {
113113 this.data = json
114114 })
115- }) */
116- this .data = Tools .getData ()
115+ })**/
116+ // this.data = Tools.getData()
117+ // this.data = [];
118+ this .count = Tools .getCount ()
117119 },
118120 data : function () {
119121 return {
224226 }
225227 },
226228 watch: {
227- data (val ) {
228- this .count = val .length
229- },
230229 showBody (val ) {
231230 if (val) {
232231 // 最大化
244243 close () {
245244 Tools .dispatchEvent (' close' )
246245 },
246+
247+ getData (callback ) {
248+ let host = ' baidu.com'
249+ fetch (` https://greasyfork.org/zh-CN/scripts/by-site/${ host} .json` )
250+ .then ((r ) => {
251+ r .json ().then ((json ) => {
252+ callback (json)
253+ })
254+ })
255+ },
256+
247257 bodySwitch () {
248- this .showBody = ! this .showBody
249- setTimeout (() => {
250- this .showTitle = this .showBody
251- }, 500 )
258+ if (this .data .length == 0 && this .showBody == false ) {
259+ this .$Spin .show ();
260+ Tools .getData ((json )=> {
261+ this .data = json
262+ this .$Spin .hide ();
263+ this .showBody = ! this .showBody
264+ setTimeout (() => {
265+ this .showTitle = this .showBody
266+ }, 500 )
267+ })
268+ }else {
269+ this .showBody = ! this .showBody
270+ setTimeout (() => {
271+ this .showTitle = this .showBody
272+ }, 500 )
273+ }
274+
252275 },
253276 open (url ) {
254277 window .open (url)
Original file line number Diff line number Diff line change @@ -83,6 +83,11 @@ class FetchUserjs {
8383 sessionStorage . setItem ( this . quietKey , 1 ) ;
8484 $ ( '#jae_userscript_box' ) . remove ( ) ;
8585 } )
86+
87+ this . addEventListener ( 'fetchData' , ( ) => {
88+ console . log ( 'fetchData' )
89+ this . getData ( this . host )
90+ } )
8691 }
8792
8893 execFrameJs ( frameWindow ) {
Original file line number Diff line number Diff line change 1818{ ljs }
1919// @resource ui https://raw.githubusercontent.com/jae-jae/Show-Site-All-UserJS/master/dist/ui.html?_={time}
2020// @resource uiJs https://raw.githubusercontent.com/jae-jae/Show-Site-All-UserJS/master/dist/ui.js?_={time}
21+ // @resource count https://greasyfork.org/scripts/by-site.json
2122// @grant GM_xmlhttpRequest
2223// @grant GM_getResourceText
2324// @grant GM_getValue
You can’t perform that action at this time.
0 commit comments