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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
"use strict";
import utils from './utils.js'
window.browser = window.browser || window.chrome;
const targets = [
/^https?:\/{2}music\.youtube\.com(\/.*|$)/,
];
let redirects = {
"beatbump": {
"normal": [
"https://beatbump.ml"
],
"tor": [],
"i2p": [],
"loki": []
},
};
let
disableYoutubeMusic,
protocol,
protocolFallback,
beatbumpNormalRedirectsChecks,
beatbumpNormalCustomRedirects,
beatbumpTorCustomRedirects,
beatbumpI2pCustomRedirects,
beatbumpLokiCustomRedirects;
function init() {
browser.storage.local.get(
[
"disableYoutubeMusic",
"protocol",
"protocolFallback",
"beatbumpNormalRedirectsChecks",
"beatbumpNormalCustomRedirects",
"beatbumpTorCustomRedirects",
"beatbumpI2pCustomRedirects",
"beatbumpLokiCustomRedirects"
],
r => {
disableYoutubeMusic = r.disableYoutubeMusic;
protocol = r.protocol;
protocolFallback = r.protocolFallback;
beatbumpNormalRedirectsChecks = r.beatbumpNormalRedirectsChecks;
beatbumpNormalCustomRedirects = r.beatbumpNormalCustomRedirects;
beatbumpTorCustomRedirects = r.beatbumpTorCustomRedirects;
beatbumpI2pCustomRedirects = r.beatbumpI2pCustomRedirects;
beatbumpLokiCustomRedirects = r.beatbumpLokiCustomRedirects;
}
)
}
init();
browser.storage.onChanged.addListener(init)
/*
Video
https://music.youtube.com/watch?v=_PkGiKBW-DA&list=RDAMVM_PkGiKBW-DA
https://beatbump.ml/listen?id=_PkGiKBW-DA&list=RDAMVM_PkGiKBW-DA
Playlist
https://music.youtube.com/playlist?list=PLqxd0OMLeWy64zlwhjouj92ISc38FbOns
https://music.youtube.com/playlist?list=PLqxd0OMLeWy7lrJSzt9LnOJjbC1IaruPM
https://music.youtube.com/playlist?list=PLQod4DlD72ZMJmOrSNbmEmK_iZ1oXPzKd
https://beatbump.ml/playlist/VLPLqxd0OMLeWy64zlwhjouj92ISc38FbOns
Channel
https://music.youtube.com/channel/UCfgmMDI7T5tOQqjnOBRe_wg
https://beatbump.ml/artist/UCfgmMDI7T5tOQqjnOBRe_wg
Albums
https://music.youtube.com/playlist?list=OLAK5uy_n-9HVh3cryV2gREZM9Sc0JwEKYjjfi0dU
https://music.youtube.com/playlist?list=OLAK5uy_lcr5O1zS8f6WIFI_yxqVp2RK9Dyy2bbw0
https://beatbump.ml/release?id=MPREb_3DURc4yEUtD
https://beatbump.ml/release?id=MPREb_evaZrV1WNdS
https://music.youtube.com/playlist?list=OLAK5uy_n6OHVllUZUCnlIY1m-gUaH8uqkN3Y-Ca8
https://music.youtube.com/playlist?list=OLAK5uy_nBOTxAc3_RGB82-Z54jdARGxGaCYlpngY
https://beatbump.ml/release?id=MPREb_QygdC0wEoLe
https://music.youtube.com/watch?v=R6gSMSYKhKU&list=OLAK5uy_n-9HVh3cryV2gREZM9Sc0JwEKYjjfi0dU
Search
https://music.youtube.com/search?q=test
https://beatbump.ml/search/test?filter=EgWKAQIIAWoKEAMQBBAKEAkQBQ%3D%3D
*/
function redirect(url, disableOverride) {
if (disableYoutubeMusic && !disableOverride) return;
if (!targets.some(rx => rx.test(url.href))) return;
let instancesList = [];
if (protocol == 'loki') instancesList = [...beatbumpLokiCustomRedirects];
else if (protocol == 'i2p') instancesList = [...beatbumpI2pCustomRedirects];
else if (protocol == 'tor') instancesList = [...beatbumpTorCustomRedirects];
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
instancesList = [...beatbumpNormalRedirectsChecks, ...beatbumpNormalCustomRedirects];
}
if (instancesList.length === 0) return;
const randomInstance = utils.getRandomInstance(instancesList);
return `${randomInstance}${url.pathname}${url.search}`
.replace("/watch?v=", "/listen?id=")
.replace("/channel/", "/artist/")
.replace("/playlist?list=", "/playlist/VL")
.replace(/\/search\?q=.*/, searchQuery => searchQuery.replace("?q=", "/") + "?filter=EgWKAQIIAWoKEAMQBBAKEAkQBQ%3D%3D");
}
async function initDefaults() {
return new Promise(resolve =>
browser.storage.local.set({
disableYoutubeMusic: true,
youtubeMusicRedirects: redirects,
beatbumpNormalRedirectsChecks: [...redirects.beatbump.normal],
beatbumpNormalCustomRedirects: [],
beatbumpTorRedirectsChecks: [...redirects.beatbump.tor],
beatbumpTorCustomRedirects: [],
beatbumpI2pRedirectsChecks: [...redirects.beatbump.i2p],
beatbumpI2pCustomRedirects: [],
beatbumpLokiRedirectsChecks: [...redirects.beatbump.loki],
beatbumpLokiCustomRedirects: []
}, () => resolve())
)
}
export default {
redirect,
initDefaults,
};
|