Skip to content

Commit 7b95404

Browse files
committed
2.4.15
Signed-off-by: Magic <magicoflolis@tuta.io>
1 parent 712a829 commit 7b95404

4 files changed

Lines changed: 282 additions & 536 deletions

File tree

dist/magic-userjs.gf.user.js

Lines changed: 139 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@
66
// @name:ja Magic Userscript+ : 現在のサイトの利用可能なすべてのUserJSスクリプトを表示するJaeger
77
// @name:ru-RU Magic Userscript+ : Показать пользовательские скрипты (UserJS) для сайта. Jaeger
88
// @name:ru Magic Userscript+ : Показать пользовательские скрипты (UserJS) для сайта. Jaeger
9-
// @description Show current site all UserJS,The easier way to install UserJs for Tampermonkey.
9+
// @description Show current site all UserJS, the easier way to install UserJs for Tampermonkey.
1010
// @description:zh 显示当前网站的所有可用UserJS(Tampermonkey)脚本,交流QQ群:104267383
1111
// @description:zh-CN 显示当前网站的所有可用UserJS(Tampermonkey)脚本,交流QQ群:104267383
1212
// @description:zh-TW 顯示當前網站的所有可用UserJS(Tampermonkey)腳本,交流QQ群:104267383
1313
// @description:ja 現在のサイトで利用可能なすべてのUserJS(Tampermonkey)スクリプトを表示します。
1414
// @description:ru-RU Показывает пользовательские скрипты (UserJS) для сайта. Легкий способ установить пользовательские скрипты для Tampermonkey.
1515
// @description:ru Показывает пользовательские скрипты (UserJS) для сайта. Легкий способ установить пользовательские скрипты для Tampermonkey.
16-
// @author Magic of Lolis <magicoflolis@gmail.com>
16+
// @author Magic <magicoflolis@tuta.io>
1717
// @namespace https://github.com/magicoflolis/Userscript-Plus
18-
// @homepageURL https://github.com/magicoflolis/Userscript-Plus#magic-userscript
18+
// @homepageURL https://github.com/magicoflolis/Userscript-Plus
19+
// @downloadURL https://cdn.jsdelivr.net/gh/magicoflolis/Userscript-Plus@master/archive/magic-userjs.user.js
20+
// @updateURL https://cdn.jsdelivr.net/gh/magicoflolis/Userscript-Plus@master/archive/magic-userjs.user.js
1921
// @supportURL https://github.com/magicoflolis/Userscript-Plus/issues/new
20-
// @version 2.3.12
22+
// @version 2.4.15
2123
// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3ggEBCQHM3fXsAAAAVdJREFUOMudkz2qwkAUhc/goBaGJBgUtBCZyj0ILkpwAW7Bws4yO3AHLiCtEFD8KVREkoiFxZzX5A2KGfN4F04zMN+ce+5c4LMUgDmANYBnrnV+plBSi+FwyHq9TgA2LQpvCiEiABwMBtzv95RSfoNEHy8DYBzHrNVqVEr9BWKcqNFoxF6vx3a7zc1mYyC73a4MogBg7vs+z+czO50OW60Wt9stK5UKp9Mpj8cjq9WqDTBHnjAdxzGQZrPJw+HA31oulzbAWgLoA0CWZVBKIY5jzGYzdLtdE9DlcrFNrY98zobqOA6TJKHW2jg4nU5sNBpFDp6mhVe5rsvVasUwDHm9Xqm15u12o+/7Hy0gD8KatOd5vN/v1FozTVN6nkchxFuI6hsAAIMg4OPxMJCXdtTbR7JJCMEgCJhlGUlyPB4XfumozInrupxMJpRSRtZlKoNYl+m/6/wDuWAjtPfsQuwAAAAASUVORK5CYII=
2224
// @license MIT
2325
// @include *
@@ -70,9 +72,8 @@
7072
// @exclude *://*.*.*/options/*
7173
// @exclude *://*.*.*.gov/*
7274
// @exclude *://*.*.*/password_reset
73-
// @require https://greasyfork.org/scripts/23419/code/ljs.js
74-
// @require https://greasyfork.org/scripts/428620/code/userjs-base.js?_=1624989578203
75-
// @resource uiJs https://cdn.jsdelivr.net/gh/magicoflolis/Userscript-Plus@master/dist/ui.gf.js?_=1624989578203
75+
// @require https://greasyfork.org/scripts/23419-l-js/code/ljs.js
76+
// @resource uiJs https://cdn.jsdelivr.net/gh/magicoflolis/Userscript-Plus@master/archive/ui.js
7677
// @resource count https://greasyfork.org/scripts/by-site.json
7778
// @resource adult https://sleazyfork.org/scripts/by-site.json
7879
// @grant GM_xmlhttpRequest
@@ -94,157 +95,155 @@
9495
* Включить встроенный "Greasyfork Поиск с Sleazyfork Результаты включают"
9596
* https://greasyfork.org/scripts/23840
9697
*/
97-
let sleazyfork_redirect = false; // "true" to enable, "false" to disable
98+
const sleazyfork_redirect = false, // 'true' to enable, 'false' to disable
99+
custom_width = '', // Default UserJS width: 90vw | Original UserJS width: 860px
100+
/**
101+
* Injected stylesheet
102+
* https://github.com/magicoflolis/Userscript-Plus/tree/master/src/sass
103+
*/
104+
boxCSS = `*:not(select){scrollbar-color:#fff #2e323d;scrollbar-width:thin}::-webkit-scrollbar{max-width:8px !important;max-height:8px !important}::-webkit-scrollbar-thumb{background:#fff}::-webkit-scrollbar-track{background-color:#2e323d}body.userjs-popup{color:#fff !important;background-color:#2e323d !important;width:800px !important;height:550px;top:0px;left:0px}body.userjs-popup #app{position:fixed;width:inherit;display:grid;grid-template-rows:repeat(4, 1fr)}body.userjs-popup #app .ivu-card{width:100%;height:100%;padding:0px}body.userjs-popup #app .ivu-card-extra{top:8px !important}body.userjs-popup #app .ivu-card-head{border-bottom:1px solid #fff !important;padding:2.5% 16px !important}body.userjs-popup #app .ivu-badge{padding:0px 5px}body.userjs-popup #app .ivu-tooltip{border-color:#fff !important;border-radius:4px !important;background-color:#fff !important}body.userjs-popup #app .ivu-btn-icon-only,body.userjs-popup #app .ivu-modal-body,body.userjs-popup #app .ivu-table{color:#fff !important;background-color:#2e323d !important}body.userjs-popup #app .ivu-btn-icon-only td,body.userjs-popup #app .ivu-btn-icon-only th,body.userjs-popup #app .ivu-modal-body td,body.userjs-popup #app .ivu-modal-body th,body.userjs-popup #app .ivu-table td,body.userjs-popup #app .ivu-table th{color:#fff !important;background-color:#2e323d !important}body.userjs-popup #app .ivu-btn-icon-only-body,body.userjs-popup #app .ivu-modal-body-body,body.userjs-popup #app .ivu-table-body{overflow-x:hidden}body.userjs-popup #app .ivu-btn-icon-only-row-highlight,body.userjs-popup #app .ivu-btn-icon-only-row-hover,body.userjs-popup #app .ivu-modal-body-row-highlight,body.userjs-popup #app .ivu-modal-body-row-hover,body.userjs-popup #app .ivu-table-row-highlight,body.userjs-popup #app .ivu-table-row-hover{color:#9cc3e7 !important}body.userjs-popup #app .card-title{color:#fff !important;cursor:pointer}body.userjs-popup #app .table-footer{position:fixed;bottom:0;padding-left:10px;width:100%;background-color:#fff}body.userjs-popup #app .table-footer a{color:#ed3f14}body.userjs-popup #app .circle{width:56px;height:56px;line-height:56px;border-radius:28px;float:right;right:40px}body.userjs-popup #app .badge{top:-17px;left:-6%;width:26px;height:26px;line-height:26px;border-radius:13px}@media screen and (max-width: 1228px){.jae-userscript{max-width:100%;width:100%;height:100%}}.jae-userscript{position:fixed;width:370px;bottom:10px;right:20px;z-index:9999999999;height:56px;background:rgba(0,0,0,0)}.jae-userscript iframe{width:100%;height:100%;border:0px;border-radius:15px;display:block !important}.jae-userscript span{background-color:#2e323d;color:#fff;width:fit-content;display:block;padding:1rem;border-radius:15px;right:10px;position:fixed}.jae-userscript-shadow{box-shadow:0 1px 4px rgba(0,0,0,.3)}.jae-userscript-shadow:after,.jae-userscript-shadow:before{content:"";position:absolute;z-index:-1;bottom:15px;left:10px;width:50%;height:20%;box-shadow:0 15px 10px rgba(0,0,0,.7)}.jae-userscript-shadow:after{right:10px;left:auto;transform:rotate(3deg)}.jae-userscript-shadow:before{transform:rotate(-3deg)}@media(prefers-color-scheme: dark){body.userjs-options :root{background-color:#202023;color:#e8eaed}body.userjs-options section:not(:first-child){border-top:1px solid #4c4c4e}}body.userjs-options form{font-size:1.25em}body.userjs-options section:not(:first-child){border-top:1px solid #4c4c4e}body.userjs-options section.checkbox>label,body.userjs-options section.checkboxlist>label,body.userjs-options section.select{display:flex;justify-content:space-between;padding:.825em}body.userjs-options section.checkbox>label,body.userjs-options section.checkboxlist>label{cursor:pointer}body.userjs-options section.checkboxlist{padding-left:.825em;padding-bottom:.5em}body.userjs-options section.checkboxlist>label{padding-top:.5em;padding-bottom:.5em}body.userjs-options section.checkboxlist p{margin-bottom:.5em}body.userjs-options .switch{position:relative;width:38px;user-select:none}body.userjs-options .switch input{display:none}body.userjs-options .switch input:checked+label{background-color:#5a6f93;margin-left:0}body.userjs-options .switch input:checked+label:before{right:0px;background-color:#8ab4f8}body.userjs-options .switch label{display:block;overflow:hidden;cursor:pointer;height:16px;padding:0;line-height:16px;border:0px solid #fff;border-radius:20px;background-color:#9aa0a6}body.userjs-options .switch label:before{content:"";display:block;width:20px;height:20px;margin:-2px;background:#dadce0;position:absolute;top:0;right:20px;border-radius:20px}`,
105+
err = (...error) => {
106+
console.error('[%cUserJS%c] %cERROR', 'color: rgb(29, 155, 240);', '', 'color: rgb(249, 24, 128);', ...error);
107+
};
98108

99-
unsafeWindow.GmAjax = GM_xmlhttpRequest;
109+
if(typeof unsafeWindow === 'undefined') {
110+
err('[%cUserJS%c] %cERROR', 'color: rgb(29, 155, 240);', '', 'color: rgb(249, 24, 128);', "Unsupported: unsafeWindow");
111+
} else {
112+
unsafeWindow.GmAjax = GM_xmlhttpRequest;
113+
};
100114

115+
/* eslint-disable no-undef */
101116
(() => {
102-
103-
const iframe = {
104-
write: (iframeDom, content) => {
105-
if (iframeDom.tagName && "iframe" == iframeDom.tagName.toLowerCase()) {
106-
let c = iframeDom.contentWindow.document;
107-
108-
try {
109-
c.open(), c.write(content), c.close();
110-
} catch (d) {
111-
console.log("append HTML to [iframe:" + iframeDom.name + "] ERROR!");
117+
ljs.addAliases({
118+
jQuery:'https://cdn.jsdelivr.net/gh/jquery/jquery/dist/jquery.slim.min.js'
119+
});
120+
const win = self ?? window,
121+
doc = win.document,
122+
qs = (element, selector) => {
123+
selector = selector ?? doc ?? doc.body;
124+
return selector.querySelector(element);
125+
},
126+
delay = ms => new Promise(resolve => setTimeout(resolve, ms)),
127+
iframe = {
128+
write: () => {
129+
const root = qs('#jae_userscript_box > .jae-userscript',doc.body),
130+
dom = root.children[0],
131+
domDoc = `<!DOCTYPE html><html>
132+
<head>
133+
<meta charset="utf-8">
134+
<title>Show Site All UserJS</title>
135+
</head>
136+
<body style="background: none transparent">
137+
<div id="app"></div>
138+
</body></html>`;
139+
if (dom.tagName && 'iframe' == dom.tagName.toLowerCase()) {
140+
let c = dom.contentDocument ?? dom.contentWindow.document;
141+
try {
142+
c.open();
143+
c.write(domDoc);
144+
c.close();
145+
} catch (d) {
146+
err(`loading { ${dom.name} }; [ ${d} ]`);
147+
if(root) {
148+
root.innerHTML = `<span>[ERROR] loading { ${dom.name} }; [ ${d} ]</span>`;
149+
delay(2500).then(() => {
150+
root.innerHTML = '';
151+
});
152+
};
153+
}
112154
}
113155
}
114-
}
115-
},
116-
qs = element => {
117-
return document.querySelector(element);
118-
},
119-
sleazy = () => {
120-
let otherSite = /greasyfork\.org/.test(location.hostname) ? "sleazyfork" : "greasyfork";
121-
qs('span.sign-in-link') ? /scripts\/\d+/.test(location.href) ? !qs("#script-info") && (otherSite == "greasyfork" || qs("div.width-constraint>section>p>a")) ? location.href = location.href.replace(/\/\/([^\.]+\.)?(greasyfork|sleazyfork)\.org/, "//$1" + otherSite + "\.org") : false : false : false;
122-
};
156+
},
157+
sleazy = () => {
158+
let otherSite = /greasyfork\.org/.test(location.hostname) ? 'sleazyfork' : 'greasyfork';
159+
qs('span.sign-in-link') ? /scripts\/\d+/.test(location.href) ? !qs('#script-info') && (otherSite == 'greasyfork' || qs('div.width-constraint>section>p>a')) ? location.href = location.href.replace(/\/\/([^.]+\.)?(greasyfork|sleazyfork)\.org/, '//$1' + otherSite + '.org') : false : false : false;
160+
};
123161

124-
class FetchUserjs {
125-
constructor() {
126-
this.host = window.location.hostname.split(".").splice(-2).join(".");
127-
this.showTime = 10;
128-
this.quietKey = "jae_fetch_userjs_quiet";
129-
this.countKey = "jae_fetch_userjs_count";
130-
this.adultKey = "jae_fetch_userjs_adult";
131-
this.tplBox = `<div id="jae_userscript_box">
132-
<style>.jae-userscript{
133-
position:fixed;
134-
width:370px;
135-
bottom:10px;
136-
right:20px;
137-
z-index:9999999999;
138-
height:56px
139-
}
140-
.jae-userscript-shadow{
141-
box-shadow:0 1px 4px rgba(0,0,0,.3);
142-
}
143-
.jae-userscript-shadow::before,
144-
.jae-userscript-shadow::after{
145-
content:"";
146-
position:absolute;
147-
z-index:-1;
148-
bottom:15px;
149-
left:10px;
150-
width:50%;
151-
height:20%;
152-
box-shadow:0 15px 10px rgba(0,0,0,.7);
153-
}
154-
.jae-userscript-shadow::before{
155-
transform:rotate(-3deg)
162+
class FetchUserjs {
163+
constructor() {
164+
this.host = win.location.hostname.split('.').splice(-2).join('.');
165+
this.showTime = 10;
166+
this.quietKey = 'jae_fetch_userjs_quiet';
167+
this.countKey = 'jae_fetch_userjs_count';
168+
this.adultKey = 'jae_fetch_userjs_adult';
169+
this.tplBox = `<div id="jae_userscript_box">
170+
<style>${boxCSS}</style>
171+
<div class="jae-userscript">
172+
<iframe class="UserJSFrame" name="jaeFetchUserJSFrame" src="about:blank" allowTransparency="true"></iframe>
173+
</div>
174+
</div>`;
156175
}
157-
.jae-userscript-shadow::after{
158-
right:10px; left:auto;
159-
transform:rotate(3deg)
176+
177+
getCountData(host) {
178+
let countData = GM_getResourceText('count');
179+
countData = JSON.parse(countData);
180+
let count = countData[host];
181+
sessionStorage.setItem(this.countKey, count);
182+
return count;
160183
}
161-
@media screen and (max-width:1228px) {
162-
.jae-userscript {
163-
max-width: 100%;
164-
width: 100%;
165-
height: 100%;
184+
185+
setSize(w, h) {
186+
if(w.trim() === '90vw') {
187+
if(custom_width.trim() !== '') {
188+
return qs('#jae_userscript_box > .jae-userscript',doc.body).setAttribute('style', `width: ${custom_width};height: ${h}px;`)
189+
}
166190
}
191+
return qs('#jae_userscript_box > .jae-userscript',doc.body).setAttribute('style', `width: ${w};height: ${h}px;`)
167192
}
168-
</style><div class="jae-userscript"></div></div>`;
169-
}
170193

171-
getCountData(host) {
172-
let countData = GM_getResourceText('count');
173-
countData = JSON.parse(countData);
174-
let count = countData[host];
175-
sessionStorage.setItem(this.countKey, count);
176-
return count;
177-
}
178-
179-
setSize(w, h) {
180-
$('.jae-userscript').css({
181-
width: w,
182-
height: h
183-
});
184-
}
185-
186-
addEventListener(eventName, handler) {
187-
qs('#jae_userscript_box').addEventListener(eventName, handler);
188-
}
189-
190-
bindEvent() {
191-
this.timeId = setTimeout(() => {
192-
qs('#jae_userscript_box').remove();
193-
}, this.showTime * 1000);
194-
this.addEventListener('max', () => {
195-
this.setSize(860, 492);
196-
$('.jae-userscript').addClass('jae-userscript-shadow');
197-
clearTimeout(this.timeId);
198-
});
199-
this.addEventListener('min', () => {
200-
$('.jae-userscript').removeClass('jae-userscript-shadow');
201-
new Promise(resolve => setTimeout(resolve, 500));
202-
this.setSize(370, 56);
203-
});
204-
this.addEventListener('close', () => {
205-
sessionStorage.setItem(this.quietKey, 1);
206-
qs('#jae_userscript_box').remove();
207-
});
208-
this.addEventListener('loading', () => {
209-
clearTimeout(this.timeId);
210-
});
211-
}
194+
addEventListener(eventName, handler) {
195+
qs('#jae_userscript_box').addEventListener(eventName, handler);
196+
}
212197

213-
execFrameJs(frameWindow) {
214-
let uiJs = GM_getResourceText('uiJs');
215-
return function (jsStr) {
216-
frameWindow.eval(jsStr);
217-
}.call(frameWindow, uiJs);
218-
}
198+
bindEvent() {
199+
this.timeId = setTimeout(() => {
200+
qs('#jae_userscript_box').remove();
201+
}, this.showTime * 1000);
202+
this.addEventListener('max', () => {
203+
this.setSize('90vw', 492);
204+
clearTimeout(this.timeId);
205+
});
206+
this.addEventListener('min', () => {
207+
this.setSize('370px', 56);
208+
});
209+
this.addEventListener('close', () => {
210+
sessionStorage.setItem(this.quietKey, 1);
211+
qs('#jae_userscript_box').remove();
212+
});
213+
this.addEventListener('loading', () => {
214+
clearTimeout(this.timeId);
215+
});
216+
}
219217

220-
get isQuiet() {
221-
let quiet = sessionStorage.getItem(this.quietKey);
222-
return quiet ? true : false;
223-
}
218+
execFrameJs(frameWindow) {
219+
let uiJs = GM_getResourceText('uiJs');
220+
return function (jsStr) {
221+
frameWindow.eval(jsStr);
222+
}.call(frameWindow, uiJs);
223+
}
224224

225-
render() {
226-
if (!this.isQuiet) {
227-
let count = this.getCountData(this.host);
225+
get isQuiet() {
226+
let quiet = sessionStorage.getItem(this.quietKey);
227+
return quiet ? true : false;
228+
}
228229

229-
if (count) {
230-
$("body").append(this.tplBox);
231-
let ui = '<!DOCTYPE html><html><head><meta charset="utf-8"><title>Show Site All UserJS</title></head><body style="background: none transparent"><div id="app"></div></body></html>',
232-
dom = document.getElementsByClassName('jae-userscript')[0];
233-
dom.innerHTML = '<iframe name="jaeFetchUserJSFrame" src="about:blank" style="width:100%;height:100%;border:0px;display: block!important;" allowTransparency="true"></iframe>';
234-
let iframeDom = dom.children[0];
235-
iframe.write(iframeDom, ui);
236-
this.execFrameJs(jaeFetchUserJSFrame.window);
237-
this.bindEvent();
230+
render() {
231+
if (!this.isQuiet) {
232+
if (this.getCountData(this.host)) {
233+
$('body').append(this.tplBox);
234+
iframe.write();
235+
this.execFrameJs(jaeFetchUserJSFrame.window);
236+
this.bindEvent();
237+
}
238238
}
239239
}
240+
240241
}
241242

242-
}
243+
let fu = new FetchUserjs();
244+
ljs.exec(['jQuery'], () => {
245+
/greasyfork\.org/.test(location.hostname) && sleazyfork_redirect ? sleazy() : false;
246+
fu.render();
247+
});
243248

244-
let fu = new FetchUserjs();
245-
ljs.exec(['jQuery'], () => {
246-
/greasyfork\.org/.test(location.hostname) && sleazyfork_redirect ? sleazy() : false;
247-
fu.render();
248-
});
249-
250249
})();

0 commit comments

Comments
 (0)