Skip to content

Commit 6efa5db

Browse files
committed
1 parent ad6595c commit 6efa5db

File tree

3 files changed

+319
-313
lines changed

3 files changed

+319
-313
lines changed

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

Lines changed: 152 additions & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3ggEBCQHM3fXsAAAAVdJREFUOMudkz2qwkAUhc/goBaGJBgUtBCZyj0ILkpwAW7Bws4yO3AHLiCtEFD8KVREkoiFxZzX5A2KGfN4F04zMN+ce+5c4LMUgDmANYBnrnV+plBSi+FwyHq9TgA2LQpvCiEiABwMBtzv95RSfoNEHy8DYBzHrNVqVEr9BWKcqNFoxF6vx3a7zc1mYyC73a4MogBg7vs+z+czO50OW60Wt9stK5UKp9Mpj8cjq9WqDTBHnjAdxzGQZrPJw+HA31oulzbAWgLoA0CWZVBKIY5jzGYzdLtdE9DlcrFNrY98zobqOA6TJKHW2jg4nU5sNBpFDp6mhVe5rsvVasUwDHm9Xqm15u12o+/7Hy0gD8KatOd5vN/v1FozTVN6nkchxFuI6hsAAIMg4OPxMJCXdtTbR7JJCMEgCJhlGUlyPB4XfumozInrupxMJpRSRtZlKoNYl+m/6/wDuWAjtPfsQuwAAAAASUVORK5CYII=
1616
// @include *
1717
// @exclude http://www.dev/Show-Site-All-UserJS/ui.html
18-
// @require https://greasyfork.org/scripts/23419-l-js/code/ljs.js?version=148792
18+
// @require https://greasyfork.org/scripts/23419-l-js/code/ljs.js?version=148792
1919
// @require https://greasyfork.org/scripts/23420-userjs-base-js/code/userjs-basejs.js?version=214700
2020
// @resource ui https://raw.githubusercontent.com/jae-jae/Show-Site-All-UserJS/master/dist/ui.html?_=1506350655256
2121
// @resource uiJs https://raw.githubusercontent.com/jae-jae/Show-Site-All-UserJS/master/dist/ui.js?_=1506350655256
@@ -34,155 +34,157 @@
3434

3535
(function() {
3636

37-
'use strict';
38-
39-
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
40-
41-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
42-
43-
var FetchUserjs = function () {
44-
function FetchUserjs() {
45-
_classCallCheck(this, FetchUserjs);
46-
47-
this.homeUrl = 'https://greasyfork.org/zh-CN/scripts/24508';
48-
this.api = 'https://greasyfork.org/en/scripts/by-site/{host}.json';
49-
this.host = location.hostname.split('.').splice(-2).join('.');
50-
this.showTime = 10;
51-
this.quietKey = 'jae_fetch_userjs_quiet';
52-
this.cacheKey = 'jae_fetch_userjs_cache';
53-
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>';
54-
}
55-
56-
/* Nano Templates - https://github.com/trix/nano */
57-
58-
59-
_createClass(FetchUserjs, [{
60-
key: 'nano',
61-
value: function nano(template, data) {
62-
return template.replace(/\{([\w\.]*)\}/g, function (str, key) {
63-
var keys = key.split("."),
64-
v = data[keys.shift()];
65-
for (var i = 0, l = keys.length; i < l; i++) {
66-
v = v[keys[i]];
67-
}return typeof v !== "undefined" && v !== null ? v : "";
68-
});
69-
}
70-
}, {
71-
key: 'getJSON',
72-
value: function getJSON(url, callback) {
73-
GM_xmlhttpRequest({
74-
method: 'GET',
75-
url: url,
76-
onload: function onload(res) {
77-
var json = JSON.parse(res.responseText);
78-
callback(json);
79-
}
80-
});
81-
}
82-
}, {
83-
key: 'getData',
84-
value: function getData(host, callback) {
85-
var _this = this;
86-
87-
var data = sessionStorage.getItem(this.cacheKey);
88-
if (data) {
89-
data = JSON.parse(data);
90-
callback(data);
91-
} else {
92-
var api = this.nano(this.api, {
93-
host: this.host
94-
});
95-
this.getJSON(api, function (json) {
96-
sessionStorage.setItem(_this.cacheKey, JSON.stringify(json));
97-
callback(json);
98-
});
99-
}
100-
}
101-
}, {
102-
key: 'setSize',
103-
value: function setSize(w, h) {
104-
$('.jae-userscript').css({
105-
width: w,
106-
height: h
107-
});
108-
}
109-
}, {
110-
key: 'addEventListener',
111-
value: function addEventListener(eventName, handler) {
112-
document.getElementById('jae_userscript_box').addEventListener(eventName, handler);
113-
}
114-
}, {
115-
key: 'bindEvent',
116-
value: function bindEvent() {
117-
var _this2 = this;
118-
119-
this.timeId = setTimeout(function () {
120-
$('#jae_userscript_box').remove();
121-
}, this.showTime * 1000);
122-
123-
this.addEventListener('max', function () {
124-
_this2.setSize(860, 492);
125-
$('.jae-userscript').addClass('jae-userscript-shadow');
126-
clearTimeout(_this2.timeId);
127-
});
128-
129-
this.addEventListener('min', function () {
130-
setTimeout(function () {
131-
$('.jae-userscript').removeClass('jae-userscript-shadow');
132-
_this2.setSize(370, 56);
133-
}, 500);
134-
});
135-
136-
this.addEventListener('close', function () {
137-
sessionStorage.setItem(_this2.quietKey, 1);
138-
$('#jae_userscript_box').remove();
139-
});
140-
}
141-
}, {
142-
key: 'execFrameJs',
143-
value: function execFrameJs(frameWindow) {
144-
var uiJs = GM_getResourceText('uiJs');
145-
return function (jsStr) {
146-
frameWindow.eval(jsStr);
147-
}.call(frameWindow, uiJs);
148-
}
149-
}, {
150-
key: 'render',
151-
value: function render() {
152-
var _this3 = this;
153-
154-
this.isQuiet || this.getData(this.host, function (json) {
155-
if (json.length) {
156-
157-
$('body').append(_this3.tplBox);
158-
159-
var ui = GM_getResourceText('ui');
160-
var dom = document.getElementsByClassName('jae-userscript')[0];
161-
var tpl = '<iframe name="jaeFetchUserJSFrame" src="about:blank" style="width:100%;height:100%;border:0px;display: block!important;" allowTransparency="true"></iframe>';
162-
dom.innerHTML = tpl;
163-
var iframeDom = dom.children[0];
164-
iframe.write(iframeDom, ui);
165-
166-
_this3.execFrameJs(jaeFetchUserJSFrame.window);
167-
168-
_this3.bindEvent();
169-
}
170-
});
171-
}
172-
}, {
173-
key: 'isQuiet',
174-
get: function get() {
175-
var quiet = sessionStorage.getItem(this.quietKey);
176-
return quiet ? true : false;
177-
}
178-
}]);
179-
180-
return FetchUserjs;
181-
}();
182-
183-
ljs.exec(['jQuery', 'iframe'], function () {
184-
var fu = new FetchUserjs();
185-
fu.render();
37+
'use strict';
38+
39+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
40+
41+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
42+
43+
var FetchUserjs = function () {
44+
function FetchUserjs() {
45+
_classCallCheck(this, FetchUserjs);
46+
47+
this.homeUrl = 'https://greasyfork.org/zh-CN/scripts/24508';
48+
this.api = 'https://greasyfork.org/en/scripts/by-site/{host}.json';
49+
this.host = location.hostname.split('.').splice(-2).join('.');
50+
this.showTime = 10;
51+
this.quietKey = 'jae_fetch_userjs_quiet';
52+
this.cacheKey = 'jae_fetch_userjs_cache';
53+
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>';
54+
}
55+
56+
/* Nano Templates - https://github.com/trix/nano */
57+
58+
59+
_createClass(FetchUserjs, [{
60+
key: 'nano',
61+
value: function nano(template, data) {
62+
return template.replace(/\{([\w\.]*)\}/g, function (str, key) {
63+
var keys = key.split("."),
64+
v = data[keys.shift()];
65+
for (var i = 0, l = keys.length; i < l; i++) {
66+
v = v[keys[i]];
67+
}return typeof v !== "undefined" && v !== null ? v : "";
68+
});
69+
}
70+
}, {
71+
key: 'getJSON',
72+
value: function getJSON(url, callback) {
73+
GM_xmlhttpRequest({
74+
method: 'GET',
75+
url: url,
76+
onload: function onload(res) {
77+
var json = JSON.parse(res.responseText);
78+
callback(json);
79+
}
80+
});
81+
}
82+
}, {
83+
key: 'getData',
84+
value: function getData(host, callback) {
85+
var _this = this;
86+
87+
var data = sessionStorage.getItem(this.cacheKey);
88+
if (data) {
89+
data = JSON.parse(data);
90+
callback(data);
91+
} else {
92+
var api = this.nano(this.api, {
93+
host: this.host
94+
});
95+
this.getJSON(api, function (json) {
96+
sessionStorage.setItem(_this.cacheKey, JSON.stringify(json));
97+
callback(json);
98+
});
99+
}
100+
}
101+
}, {
102+
key: 'setSize',
103+
value: function setSize(w, h) {
104+
$('.jae-userscript').css({
105+
width: w,
106+
height: h
107+
});
108+
}
109+
}, {
110+
key: 'addEventListener',
111+
value: function addEventListener(eventName, handler) {
112+
document.getElementById('jae_userscript_box').addEventListener(eventName, handler);
113+
}
114+
}, {
115+
key: 'bindEvent',
116+
value: function bindEvent() {
117+
var _this2 = this;
118+
119+
this.timeId = setTimeout(function () {
120+
$('#jae_userscript_box').remove();
121+
}, this.showTime * 1000);
122+
123+
this.addEventListener('max', function () {
124+
_this2.setSize(860, 492);
125+
$('.jae-userscript').addClass('jae-userscript-shadow');
126+
clearTimeout(_this2.timeId);
127+
});
128+
129+
this.addEventListener('min', function () {
130+
setTimeout(function () {
131+
$('.jae-userscript').removeClass('jae-userscript-shadow');
132+
_this2.setSize(370, 56);
133+
}, 500);
134+
});
135+
136+
this.addEventListener('close', function () {
137+
sessionStorage.setItem(_this2.quietKey, 1);
138+
$('#jae_userscript_box').remove();
139+
});
140+
}
141+
}, {
142+
key: 'execFrameJs',
143+
value: function execFrameJs(frameWindow) {
144+
var uiJs = GM_getResourceText('uiJs');
145+
return function (jsStr) {
146+
frameWindow.eval(jsStr);
147+
}.call(frameWindow, uiJs);
148+
}
149+
}, {
150+
key: 'render',
151+
value: function render() {
152+
var _this3 = this;
153+
154+
if (!this.isQuiet) {
155+
this.getData(this.host, function (json) {
156+
if (json.length) {
157+
158+
$('body').append(_this3.tplBox);
159+
160+
var ui = GM_getResourceText('ui');
161+
var dom = document.getElementsByClassName('jae-userscript')[0];
162+
var tpl = '<iframe name="jaeFetchUserJSFrame" src="about:blank" style="width:100%;height:100%;border:0px;display: block!important;" allowTransparency="true"></iframe>';
163+
dom.innerHTML = tpl;
164+
var iframeDom = dom.children[0];
165+
iframe.write(iframeDom, ui);
166+
167+
_this3.execFrameJs(jaeFetchUserJSFrame.window);
168+
169+
_this3.bindEvent();
170+
}
171+
});
172+
}
173+
}
174+
}, {
175+
key: 'isQuiet',
176+
get: function get() {
177+
var quiet = sessionStorage.getItem(this.quietKey);
178+
return quiet ? true : false;
179+
}
180+
}]);
181+
182+
return FetchUserjs;
183+
}();
184+
185+
ljs.exec(['jQuery', 'iframe'], function () {
186+
var fu = new FetchUserjs();
187+
fu.render();
186188
});
187189

188190
})();

0 commit comments

Comments
 (0)