| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,14 +38,23 @@ var inline_src = (<><![CDATA[ | |||
| 38 | 38 | class FetchUserjs{ | |
| 39 | 39 | constructor(){ | |
| 40 | 40 | this.homeUrl = 'https://greasyfork.org/zh-CN/scripts/24508'; | |
| 41 | - this.api = 'https://greasyfork.org/en/scripts/by-site/${host}.json'; | ||
| 41 | + this.api = 'https://greasyfork.org/en/scripts/by-site/{host}.json'; | ||
| 42 | 42 | this.host = location.host.split('.').splice(-2).join('.'); | |
| 43 | 43 | this.showTime = 10; | |
| 44 | 44 | this.quietKey = 'jae_fetch_userjs_quiet'; | |
| 45 | 45 | this.cacheKey = 'jae_fetch_userjs_cache'; | |
| 46 | 46 | this.tplBox = '<div id="jae_userscript_box"><style>.jae-userscript{position:fixed;width:370px;bottom:10px;right:20px;z-index:9999999999;height:56px}.jae-userscript-shadow{box-shadow:0 1px 4px rgba(0,0,0,.3),\\t\\t\\t\\t0px 0 20px rgba(0,0,0,.1) inset}.jae-userscript-shadow::before,.jae-userscript-shadow::after{content:"";position:absolute;z-index:-1}.jae-userscript-shadow::before,.jae-userscript-shadow::after{content:"";position:absolute;z-index:-1;bottom:15px;left:10px;width:50%;height:20%}.jae-userscript-shadow::before,.jae-userscript-shadow::after{content:"";position:absolute;z-index:-1;bottom:15px;left:10px;width:50%;height:20%;box-shadow:0 15px 10px rgba(0,0,0,.7);transform:rotate(-3deg)}.jae-userscript-shadow::after{right:10px;left:auto;transform:rotate(3deg)}</style><div class="jae-userscript" class=""></div></div>'; | |
| 47 | 47 | } | |
| 48 | 48 | ||
| 49 | + /* Nano Templates - https://github.com/trix/nano */ | ||
| 50 | + nano(template, data) { | ||
| 51 | + return template.replace(/\{([\w\.]*)\}/g, function(str, key) { | ||
| 52 | + let keys = key.split("."), v = data[keys.shift()]; | ||
| 53 | + for (let i = 0, l = keys.length; i < l; i++) v = v[keys[i]]; | ||
| 54 | + return (typeof v !== "undefined" && v !== null) ? v : ""; | ||
| 55 | + }); | ||
| 56 | + } | ||
| 57 | + | ||
| 49 | 58 | getJSON(url,callback){ | |
| 50 | 59 | GM_xmlhttpRequest({ | |
| 51 | 60 | method:'GET', | |
@@ -66,7 +75,7 @@ var inline_src = (<><![CDATA[ | |||
| 66 | 75 | callback(data); | |
| 67 | 76 | ||
| 68 | 77 | }else{ | |
| 69 | - let api = juicer(this.api,{host:this.host}); | ||
| 78 | + let api = this.nano(this.api,{host:this.host}); | ||
| 70 | 79 | this.getJSON(api,(json)=>{ | |
| 71 | 80 | sessionStorage.setItem(this.cacheKey,JSON.stringify(json)); | |
| 72 | 81 | callback(json); | |
@@ -142,7 +151,7 @@ var inline_src = (<><![CDATA[ | |||
| 142 | 151 | ||
| 143 | 152 | } | |
| 144 | 153 | ||
| 145 | - ljs.exec(['jQuery','juicer','iframe'],()=>{ | ||
| 154 | + ljs.exec(['jQuery','iframe'],()=>{ | ||
| 146 | 155 | let fu = new FetchUserjs(); | |
| 147 | 156 | fu.render(); | |
| 148 | 157 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments