This repository has been archived by the owner on Apr 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
linkage.js
75 lines (74 loc) · 1.91 KB
/
linkage.js
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
(function(){
var _ = function(m,r)
{
if("babelfish" in window)
return window.babelfish.translate(m,r);
return m;
};
var linkage = {
forceShow: false,
media: null,
enabled: function()
{
return "senpai" in window && window.senpai.enabled();
},
setup: function()
{
API.on(API.ADVANCE, function(value){ window.linkage.advance(value); });
},
startup: function()
{
window.freshy.systemLoaded('linkage');
},
advance: function(value)
{
if(!window.linkage.enabled())
return;
if(window.linkage.timeout)
clearTimeout(window.linkage.timeout);
window.linkage.timeout = setTimeout(window.linkage.startCheck, 5000);
},
startCheck: function()
{
if(!window.linkage.enabled())
return;
window.linkage.timeout = false;
var media = API.getMedia();
if(media.cid == window.linkage.media)
return;
window.linkage.media = media.cid;
setTimeout(function(){ if(window.linkage.media == media.cid) window.linkage.media = null; }, 20000);
var dj = API.getDJ();
$.getJSON(
'https://i.animemusic.me/animemusic/check.php?dj=' + dj.id + '&id=' + media.cid + '&source=linkage',
function(r){ window.linkage.checkResult(r, media, dj); }
);
},
checkResult: function(result, media, dj)
{
if(!window.linkage.enabled())
return;
if (result == false || result.id != API.getMedia().cid)
return;
if(!result.alt)
window.chatalert.show(
'icon-volume-off', _('Unlinked song'),
_('{author} - {title} is not linked!', {'{author}':media.author,'{title}':media.title})+'<br>'+
'<a href="https://i.animemusic.me/animemusic/suggest.php?cid='+result.id+'" target="_new">'+_('Link this song now')+'</a>',
'00d2ff', 'linkage'
);
},
timeout: false
};
if(!("linkage" in window))
{
window.linkage = linkage;
window.linkage.setup();
window.linkage.startup();
}
else
{
window.linkage = linkage;
window.linkage.startup();
}
})();