mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-16 20:52:06 +00:00
Migrate adblock plugin to adblock-rs
This commit is contained in:
37
plugins/adblocker/downloader.js
Normal file
37
plugins/adblocker/downloader.js
Normal file
@ -0,0 +1,37 @@
|
||||
// This file downloads the configured adblock lists
|
||||
const fs = require("fs");
|
||||
const https = require("https");
|
||||
const path = require("path");
|
||||
|
||||
const SOURCES = [
|
||||
{
|
||||
name: "youtube-ads",
|
||||
url:
|
||||
"https://raw.githubusercontent.com/kbinani/adblock-youtube-ads/master/signed.txt"
|
||||
}
|
||||
];
|
||||
|
||||
function downloadAdblockLists(sources = SOURCES) {
|
||||
// fetch updated versions
|
||||
sources.forEach(source => {
|
||||
console.log(`Downloading list "${source.name}" (${source.url})`);
|
||||
https
|
||||
.get(source.url, response => {
|
||||
const filepath = path.resolve(
|
||||
__dirname,
|
||||
"filter-lists",
|
||||
`${source.name}.txt`
|
||||
);
|
||||
const file = fs.createWriteStream(filepath);
|
||||
response.pipe(file);
|
||||
})
|
||||
.on("error", err => {
|
||||
console.log("Error: " + err.message);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = downloadAdblockLists;
|
||||
if (require.main === module) {
|
||||
downloadAdblockLists();
|
||||
}
|
||||
Reference in New Issue
Block a user