-
Notifications
You must be signed in to change notification settings - Fork 7
/
difm.user.js
80 lines (73 loc) · 1.98 KB
/
difm.user.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
76
77
78
79
80
// ==UserScript==
// @name Di.fm Ad silencer
// @namespace http://qmegas.info/difm
// @version 3.3
// @description Remove ads on di.fm radio
// @include https://*.di.fm/*
// @include https://*.classicalradio.com/*
// @include https://*.radiotunes.com/*
// @include https://*.jazzradio.com/*
// @include https://*.rockradio.com/*
// @copyright Megas (qmegas.info)
// @grant none
//
// ==/UserScript==
(() => {
const logger = msg => {
const t = new Date();
const timeStr = di.math.pad(t.getHours()) + ":" + di.math.pad(t.getMinutes()) + ":" + di.math.pad(t.getSeconds()) + "." + t.getMilliseconds();
console.log('[' + timeStr + '] Ad silencer - ' + msg);
};
const silencer = {
method1Silence: () => {
di.app.vent.on("webplayer:ad:begin", () => {
const muting = () => {
if (!di.app.request("webplayer:muted")) {
logger('muting try');
di.app.commands.execute("webplayer:mute");
setTimeout(muting, 300);
}
};
muting();
});
di.app.vent.on("webplayer:ad:end", () => {
logger('unmuting');
di.app.commands.execute("webplayer:unmute");
});
},
method2Remover: () => {
di.app.reqres.setHandler('webplayer:interruptible', () => {
logger('handled interruptible = false');
return false;
});
di.app.reqres.setHandler('webplayer:ads:requestMidrollAd', () => {
logger('handled requestMidrollAd');
return {
fail: e => {
logger('requestMidrollAd fail');
e();
},
done: e => false,
};
});
},
method3RemoverExperimental: () => di.app.WebplayerApp.Ads.Supervisor.timers.session.stop(),
keepActive: () => setInterval(() => di.app.vent.trigger("user:active"), 60000),
};
const initVars = () => {
if (!di || !di.app || !di.app.vent) {
return false;
}
logger('init');
silencer.method1Silence();
silencer.method2Remover();
silencer.keepActive();
return true;
};
const init = () => {
if (!initVars()) {
setTimeout(init, 1000);
}
};
$(init());
})();