Skip to content

Commit 78a0484

Browse files
committed
add dist
1 parent 9523624 commit 78a0484

4 files changed

Lines changed: 176 additions & 1 deletion

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
node_modules/
2-
dist/

dist/show-site-all-userjs.user.js

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
// ==UserScript==
2+
// @name Show Site All UserJS
3+
// @name:zh 显示当前网站所有可用的UserJS脚本 Jaeger
4+
// @name:zh-CN 显示当前网站所有可用的UserJS脚本 Jaeger
5+
// @namespace https://gist.github.com/jae-jae/39d526079cb2408389129caf98debc29
6+
// @version 2.0
7+
// @description 显示当前网站的所有可用UserJS(Tampermonkey)脚本,交流QQ群:104267383
8+
// @author Jaeger <JaegerCode@gmail.com>
9+
// @icon https://greasyfork.org/assets/blacklogo16-bc64b9f7afdc9be4cbfa58bdd5fc2e5c098ad4bca3ad513a27b15602083fd5bc.png
10+
// @include *
11+
// @exclude http://www.dev/Show-Site-All-UserJS/ui.html
12+
// @require https://cdn.bootcss.com/babel-core/5.6.15/browser-polyfill.min.js
13+
// @require https://cdn.bootcss.com/babel-core/5.6.15/browser.min.js
14+
// @require https://raw.githubusercontent.com/jae-jae/l.js/master/userjs/l.userjs.min.js
15+
// @require https://gist.githubusercontent.com/jae-jae/35a1833079d26e6c9d9c6d5bed982353/raw/userjs-base.js
16+
// @resource ui http://www.dev/Show-Site-All-UserJS/dist/ui.html?xfg45
17+
// @resource uiJs http://www.dev/Show-Site-All-UserJS/dist/ui.js
18+
// @grant GM_xmlhttpRequest
19+
// @grant GM_getResourceText
20+
// @grant GM_getValue
21+
// @grant GM_setValue
22+
// @noframes
23+
// @connect cdn.bootcss.com
24+
// @connect raw.githubusercontent.com
25+
// @connect gist.githubusercontent.com
26+
// @connect greasyfork.org
27+
// ==/UserScript==
28+
29+
30+
/* jshint ignore:start */
31+
var inline_src = (<><![CDATA[
32+
/* jshint ignore:end */
33+
/* jshint esnext: true */
34+
35+
class FetchUserjs{
36+
constructor(){
37+
this.homeUrl = 'https://greasyfork.org/zh-CN/scripts/24508';
38+
this.api = 'https://greasyfork.org/en/scripts/by-site/${host}.json';
39+
this.host = location.host.split('.').splice(-2).join('.');
40+
this.showTime = 10;
41+
this.quietKey = 'jae_fetch_userjs_quiet';
42+
this.cacheKey = 'jae_fetch_userjs_cache';
43+
this.tplBox = '<div id="jae_fetch_userjs_wrapper"><style> #jae_fetch_userjs { position: fixed; width: 370px; bottom: 10px; right: 20px; z-index: 9999999999; height: 51px;box-shadow: 0px 1px 4px rgba(0,0,0,0.3),\t\t\t\t0px 0px 20px rgba(0,0,0,0.1) inset; }#jae_fetch_userjs::before,#jae_fetch_userjs::after { content:""; position:absolute; z-index:-1;}#jae_fetch_userjs::before,#jae_fetch_userjs::after { content:""; position:absolute; z-index:-1; bottom:15px; left:10px; width:50%; height:20%;}#jae_fetch_userjs::before,#jae_fetch_userjs::after { content:""; position:absolute; z-index:-1; bottom:15px; left:10px; width:50%; height:20%; box-shadow:0 15px 10px rgba(0, 0, 0, 0.7); transform:rotate(-3deg);}#jae_fetch_userjs::after{ right:10px; left:auto; transform:rotate(3deg); }</style><div id="jae_fetch_userjs" class=""></div></div>';
44+
}
45+
46+
getJSON(url,callback){
47+
GM_xmlhttpRequest({
48+
method:'GET',
49+
url:url,
50+
onload:(res)=>{
51+
let json = JSON.parse(res.responseText);
52+
callback(json);
53+
}
54+
});
55+
}
56+
57+
getData(host,callback){
58+
59+
let data = sessionStorage.getItem(this.cacheKey);
60+
if(data)
61+
{
62+
data = JSON.parse(data);
63+
callback(data);
64+
65+
}else{
66+
let api = juicer(this.api,{host:this.host});
67+
this.getJSON(api,(json)=>{
68+
sessionStorage.setItem(this.cacheKey,JSON.stringify(json));
69+
callback(json);
70+
});
71+
}
72+
73+
74+
}
75+
76+
setSize(w,h){
77+
$('#jae_fetch_userjs').css({width:w,height:h})
78+
}
79+
80+
addEventListener(eventName,handler){
81+
document.getElementById('jae_fetch_userjs').addEventListener(eventName,handler)
82+
}
83+
84+
bindEvent(){
85+
this.timeId = setTimeout(()=>{
86+
$('#jae_fetch_userjs_wrapper').remove();
87+
},this.showTime*1000);
88+
89+
this.addEventListener('max',()=>{
90+
this.setSize(860,492)
91+
clearTimeout(this.timeId);
92+
})
93+
94+
this.addEventListener('min',()=>{
95+
setTimeout(()=>{
96+
this.setSize(370,51)
97+
},800)
98+
})
99+
100+
this.addEventListener('close',()=>{
101+
sessionStorage.setItem(this.quietKey,1);
102+
$('#jae_fetch_userjs_wrapper').remove();
103+
})
104+
}
105+
106+
execFrameJs(frameWindow){
107+
let uiJs = GM_getResourceText('uiJs');
108+
return function(jsStr){
109+
frameWindow.eval(jsStr);
110+
}.call(frameWindow,uiJs);
111+
}
112+
113+
get isQuiet(){
114+
let quiet = sessionStorage.getItem(this.quietKey);
115+
return quiet?true:false;
116+
}
117+
118+
render(){
119+
this.isQuiet || this.getData(this.host,(json)=>{
120+
if(json.length){
121+
122+
$('body').append(this.tplBox);
123+
124+
let ui = GM_getResourceText('ui');
125+
let dom = document.getElementById('jae_fetch_userjs')
126+
var tpl = '<iframe name="jaeFetchUserJSFrame" src="about:blank" style="width:100%;height:100%;border:0px;display: block!important;" allowTransparency="true"></iframe>';
127+
dom.innerHTML = tpl;
128+
var iframeDom = dom.children[0];
129+
iframe.write(iframeDom,ui);
130+
131+
this.execFrameJs(jaeFetchUserJSFrame.window);
132+
133+
this.bindEvent();
134+
}
135+
});
136+
}
137+
138+
}
139+
140+
ljs.exec(['jQuery','juicer','iframe'],()=>{
141+
let fu = new FetchUserjs();
142+
fu.render();
143+
});
144+
145+
/* jshint ignore:start */
146+
]]></>).toString();
147+
var c = babel.transform(inline_src);
148+
eval(c.code);
149+
/* jshint ignore:end */

dist/ui.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<title>Show Site All UserJS</title>
7+
</head>
8+
9+
<body style="background: none transparent">
10+
<div id="app">
11+
12+
</div>
13+
14+
</body>
15+
16+
</html>

dist/ui.js

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)