forked from magicoflolis/Userscript-Plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsleazyfork.js
More file actions
28 lines (27 loc) 路 1.09 KB
/
Copy pathsleazyfork.js
File metadata and controls
28 lines (27 loc) 路 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"use strict";
const brws = (typeof browser=="undefined"?chrome:browser),
win = self ?? window,
doc = win.document,
err = (...error) => {
console.error('[%cUserJS%c] %cERROR', 'color: rgb(237,63,20);', '', 'color: rgb(249, 24, 128);', ...error);
},
info = (...message) =>{
console.info('[%cUserJS%c] %cINF', 'color: rgb(237,63,20);', '', 'color: rgb(0, 186, 124);', ...message);
},
getConfig = async (n) => {
let sender = brws.runtime.sendMessage({
name: n
}),
response = await sender.then(r => r.value);
return response;
},
qs = element => doc.querySelector(element);
getConfig("sleazyfork").then((r) => {
if(r) {
let otherSite = /greasyfork\.org/.test(location.hostname) ? "sleazyfork" : "greasyfork";
return 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;
}
});
getConfig("theme").then((r) => {
r === "light" ? info("WIP") : false;
});