mirror of
https://github.com/Mastermindzh/tidal-hifi.git
synced 2024-11-22 05:23:09 +01:00
adblocking thanks to custom ad filters
derived from uBlock Origin: https://github.com/uBlockOrigin/uAssets/issues/17495
This commit is contained in:
parent
eb93fbc35d
commit
26c8a38350
23
README.md
23
README.md
@ -11,24 +11,25 @@ The web version of [listen.tidal.com](https://listen.tidal.com) running in elect
|
|||||||
|
|
||||||
<!-- toc -->
|
<!-- toc -->
|
||||||
|
|
||||||
|
- [Table of contents](#table-of-contents)
|
||||||
- [Installation](#installation)
|
- [Installation](#installation)
|
||||||
* [Using releases](#using-releases)
|
- [Using releases](#using-releases)
|
||||||
* [Snap](#snap)
|
- [Snap](#snap)
|
||||||
* [Arch Linux](#arch-linux)
|
- [Arch Linux](#arch-linux)
|
||||||
* [Flatpak](#flatpak)
|
- [Flatpak](#flatpak)
|
||||||
* [Nix](#nix)
|
- [Nix](#nix)
|
||||||
* [Using source](#using-source)
|
- [Using source](#using-source)
|
||||||
- [Features](#features)
|
- [Features](#features)
|
||||||
- [Integrations](#integrations)
|
- [Integrations](#integrations)
|
||||||
* [Known bugs](#known-bugs)
|
- [Known bugs](#known-bugs)
|
||||||
+ [last.fm doesn't work out of the box. Use rescrobbler as a workaround](#lastfm-doesnt-work-out-of-the-box-use-rescrobbler-as-a-workaround)
|
- [last.fm doesn't work out of the box. Use rescrobbler as a workaround](#lastfm-doesnt-work-out-of-the-box-use-rescrobbler-as-a-workaround)
|
||||||
- [Why](#why)
|
- [Why](#why)
|
||||||
- [Why not extend existing projects?](#why-not-extend-existing-projects)
|
- [Why not extend existing projects?](#why-not-extend-existing-projects)
|
||||||
- [Special thanks to...](#special-thanks-to)
|
- [Special thanks to...](#special-thanks-to)
|
||||||
- [Buy me a coffee? Please don't](#buy-me-a-coffee-please-dont)
|
- [Buy me a coffee? Please don't](#buy-me-a-coffee-please-dont)
|
||||||
- [Images](#images)
|
- [Images](#images)
|
||||||
* [Settings window](#settings-window)
|
- [Settings window](#settings-window)
|
||||||
* [User setups](#user-setups)
|
- [User setups](#user-setups)
|
||||||
|
|
||||||
<!-- tocstop -->
|
<!-- tocstop -->
|
||||||
|
|
||||||
@ -93,7 +94,7 @@ To install and work with the code on this project follow these steps:
|
|||||||
- Notifications
|
- Notifications
|
||||||
- Custom hotkeys ([source](https://defkey.com/tidal-desktop-shortcuts))
|
- Custom hotkeys ([source](https://defkey.com/tidal-desktop-shortcuts))
|
||||||
- API for status and playback
|
- API for status and playback
|
||||||
- [Mute artists automatically (defaults to "Tidal")]("./docs/muting-artists.md")
|
- Block ads and enable video playback thanks to uBlock Origin custom filters (breakage is possible)
|
||||||
- Custom [integrations](#integrations)
|
- Custom [integrations](#integrations)
|
||||||
- [Settings feature](./docs/settings.png) to disable certain functionality. (`ctrl+=` or `ctrl+0`)
|
- [Settings feature](./docs/settings.png) to disable certain functionality. (`ctrl+=` or `ctrl+0`)
|
||||||
- AlbumArt in integrations ([best-effort](https://github.com/Mastermindzh/tidal-hifi/pull/88#pullrequestreview-840814847))
|
- AlbumArt in integrations ([best-effort](https://github.com/Mastermindzh/tidal-hifi/pull/88#pullrequestreview-840814847))
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
# Muting artists
|
|
||||||
|
|
||||||
If you feel that some of your music is embarrassing for others you can mute specific artists in the settings window.
|
|
||||||
This functionality is inspired by the [adblock ticket](https://github.com/Mastermindzh/tidal-hifi/issues/112), and whilst I personally feel you should simply buy Tidal, I also believe in muting sound that you don't want to hear.
|
|
||||||
|
|
||||||
Anyway, to block an artist, open the settings window (see image below) and enter a list of artists in the textarea as seen below.
|
|
||||||
Don't forget to turn the feature on and Tidal-hifi will automatically mute the player whenever that artist is playing.
|
|
||||||
|
|
||||||
This will allow you to skip the song without anyone noticing. (you can always say "no idea, it seems to have no audio").
|
|
||||||
|
|
||||||
![muted artists settings window](./settings-muted-artists.png)
|
|
Binary file not shown.
Before Width: | Height: | Size: 103 KiB |
@ -13,10 +13,9 @@ const settings = {
|
|||||||
api: "api",
|
api: "api",
|
||||||
menuBar: "menuBar",
|
menuBar: "menuBar",
|
||||||
playBackControl: "playBackControl",
|
playBackControl: "playBackControl",
|
||||||
muteArtists: "muteArtists",
|
|
||||||
mutedArtists: "mutedArtists",
|
|
||||||
skipArtists: "skipArtists",
|
skipArtists: "skipArtists",
|
||||||
skippedArtists: "skippedArtists",
|
skippedArtists: "skippedArtists",
|
||||||
|
adBlock: "adBlock",
|
||||||
disableBackgroundThrottle: "disableBackgroundThrottle",
|
disableBackgroundThrottle: "disableBackgroundThrottle",
|
||||||
apiSettings: {
|
apiSettings: {
|
||||||
root: "apiSettings",
|
root: "apiSettings",
|
||||||
|
12
src/main.js
12
src/main.js
@ -1,5 +1,5 @@
|
|||||||
require("@electron/remote/main").initialize();
|
require("@electron/remote/main").initialize();
|
||||||
const { app, BrowserWindow, components, globalShortcut, ipcMain, protocol } = require("electron");
|
const { app, BrowserWindow, components, globalShortcut, ipcMain, protocol, session } = require("electron");
|
||||||
const {
|
const {
|
||||||
settings,
|
settings,
|
||||||
store,
|
store,
|
||||||
@ -146,6 +146,16 @@ function addGlobalShortcuts() {
|
|||||||
app.on("ready", async () => {
|
app.on("ready", async () => {
|
||||||
if (isMainInstanceOrMultipleInstancesAllowed()) {
|
if (isMainInstanceOrMultipleInstancesAllowed()) {
|
||||||
await components.whenReady();
|
await components.whenReady();
|
||||||
|
|
||||||
|
// Adblock
|
||||||
|
if (store.get(settings.adBlock)) {
|
||||||
|
const filter = { urls: ["https://listen.tidal.com/*"] };
|
||||||
|
session.defaultSession.webRequest.onBeforeRequest(filter, (details, callback) => {
|
||||||
|
if (details.url.match(/\d\?country/)) callback({ cancel: true });
|
||||||
|
else callback({ cancel: false });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
createWindow();
|
createWindow();
|
||||||
addMenu(mainWindow);
|
addMenu(mainWindow);
|
||||||
createSettingsWindow();
|
createSettingsWindow();
|
||||||
|
@ -3,15 +3,14 @@ let trayIcon,
|
|||||||
mpris,
|
mpris,
|
||||||
enableCustomHotkeys,
|
enableCustomHotkeys,
|
||||||
enableDiscord,
|
enableDiscord,
|
||||||
muteArtists,
|
|
||||||
skipArtists,
|
skipArtists,
|
||||||
notifications,
|
notifications,
|
||||||
playBackControl,
|
playBackControl,
|
||||||
api,
|
api,
|
||||||
port,
|
port,
|
||||||
menuBar,
|
menuBar,
|
||||||
mutedArtists,
|
|
||||||
skippedArtists,
|
skippedArtists,
|
||||||
|
adBlock,
|
||||||
disableBackgroundThrottle,
|
disableBackgroundThrottle,
|
||||||
singleInstance,
|
singleInstance,
|
||||||
disableHardwareMediaKeys,
|
disableHardwareMediaKeys,
|
||||||
@ -36,10 +35,9 @@ function refreshSettings() {
|
|||||||
enableCustomHotkeys.checked = store.get(settings.enableCustomHotkeys);
|
enableCustomHotkeys.checked = store.get(settings.enableCustomHotkeys);
|
||||||
enableDiscord.checked = store.get(settings.enableDiscord);
|
enableDiscord.checked = store.get(settings.enableDiscord);
|
||||||
minimizeOnClose.checked = store.get(settings.minimizeOnClose);
|
minimizeOnClose.checked = store.get(settings.minimizeOnClose);
|
||||||
muteArtists.checked = store.get(settings.muteArtists);
|
|
||||||
mutedArtists.value = store.get(settings.mutedArtists).join("\n");
|
|
||||||
skipArtists.checked = store.get(settings.skipArtists);
|
skipArtists.checked = store.get(settings.skipArtists);
|
||||||
skippedArtists.value = store.get(settings.skippedArtists).join("\n");
|
skippedArtists.value = store.get(settings.skippedArtists).join("\n");
|
||||||
|
adBlock.checked = store.get(settings.adBlock);
|
||||||
singleInstance.checked = store.get(settings.singleInstance);
|
singleInstance.checked = store.get(settings.singleInstance);
|
||||||
disableHardwareMediaKeys.checked = store.get(settings.flags.disableHardwareMediaKeys);
|
disableHardwareMediaKeys.checked = store.get(settings.flags.disableHardwareMediaKeys);
|
||||||
gpuRasterization.checked = store.get(settings.flags.gpuRasterization);
|
gpuRasterization.checked = store.get(settings.flags.gpuRasterization);
|
||||||
@ -121,10 +119,9 @@ window.addEventListener("DOMContentLoaded", () => {
|
|||||||
mpris = get("mprisCheckbox");
|
mpris = get("mprisCheckbox");
|
||||||
enableCustomHotkeys = get("enableCustomHotkeys");
|
enableCustomHotkeys = get("enableCustomHotkeys");
|
||||||
enableDiscord = get("enableDiscord");
|
enableDiscord = get("enableDiscord");
|
||||||
muteArtists = get("muteArtists");
|
|
||||||
mutedArtists = get("mutedArtists");
|
|
||||||
skipArtists = get("skipArtists");
|
skipArtists = get("skipArtists");
|
||||||
skippedArtists = get("skippedArtists");
|
skippedArtists = get("skippedArtists");
|
||||||
|
adBlock = get("adBlock");
|
||||||
disableBackgroundThrottle = get("disableBackgroundThrottle");
|
disableBackgroundThrottle = get("disableBackgroundThrottle");
|
||||||
singleInstance = get("singleInstance");
|
singleInstance = get("singleInstance");
|
||||||
disableHardwareMediaKeys = get("disableHardwareMediaKeys");
|
disableHardwareMediaKeys = get("disableHardwareMediaKeys");
|
||||||
@ -142,10 +139,9 @@ window.addEventListener("DOMContentLoaded", () => {
|
|||||||
addInputListener(enableCustomHotkeys, settings.enableCustomHotkeys);
|
addInputListener(enableCustomHotkeys, settings.enableCustomHotkeys);
|
||||||
addInputListener(enableDiscord, settings.enableDiscord);
|
addInputListener(enableDiscord, settings.enableDiscord);
|
||||||
addInputListener(minimizeOnClose, settings.minimizeOnClose);
|
addInputListener(minimizeOnClose, settings.minimizeOnClose);
|
||||||
addInputListener(muteArtists, settings.muteArtists);
|
|
||||||
addTextAreaListener(mutedArtists, settings.mutedArtists);
|
|
||||||
addInputListener(skipArtists, settings.skipArtists);
|
addInputListener(skipArtists, settings.skipArtists);
|
||||||
addTextAreaListener(skippedArtists, settings.skippedArtists);
|
addTextAreaListener(skippedArtists, settings.skippedArtists);
|
||||||
|
addInputListener(adBlock, settings.adBlock);
|
||||||
addInputListener(disableBackgroundThrottle, settings.disableBackgroundThrottle);
|
addInputListener(disableBackgroundThrottle, settings.disableBackgroundThrottle);
|
||||||
addInputListener(singleInstance, settings.singleInstance);
|
addInputListener(singleInstance, settings.singleInstance);
|
||||||
addInputListener(disableHardwareMediaKeys, settings.flags.disableHardwareMediaKeys);
|
addInputListener(disableHardwareMediaKeys, settings.flags.disableHardwareMediaKeys);
|
||||||
|
@ -52,17 +52,6 @@
|
|||||||
<span class="switch__slider"></span>
|
<span class="switch__slider"></span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="group__option">
|
|
||||||
<div class="group__description">
|
|
||||||
<h4>Mute Artists automatically</h4>
|
|
||||||
<p>The following list of artists (1 per line) will be muted automatically.</p>
|
|
||||||
</div>
|
|
||||||
<label class="switch">
|
|
||||||
<input id="muteArtists" type="checkbox">
|
|
||||||
<span class="switch__slider"></span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<textarea id="mutedArtists" class="textarea" cols="40" rows="5" spellcheck="false"></textarea>
|
|
||||||
<div class="group__option">
|
<div class="group__option">
|
||||||
<div class="group__description">
|
<div class="group__description">
|
||||||
<h4>Skip Artists automatically</h4>
|
<h4>Skip Artists automatically</h4>
|
||||||
@ -74,6 +63,16 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<textarea id="skippedArtists" class="textarea" cols="40" rows="5" spellcheck="false"></textarea>
|
<textarea id="skippedArtists" class="textarea" cols="40" rows="5" spellcheck="false"></textarea>
|
||||||
|
<div class="group__option">
|
||||||
|
<div class="group__description">
|
||||||
|
<h4>Block ads</h4>
|
||||||
|
<p>Enjoys ad-free playback with video feature enabled for free accounts.</p>
|
||||||
|
</div>
|
||||||
|
<label class="switch">
|
||||||
|
<input id="adBlock" type="checkbox">
|
||||||
|
<span class="switch__slider"></span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="group">
|
<div class="group">
|
||||||
|
@ -13,7 +13,6 @@ const appName = "Tidal Hifi";
|
|||||||
let currentSong = "";
|
let currentSong = "";
|
||||||
let player;
|
let player;
|
||||||
let currentPlayStatus = statuses.paused;
|
let currentPlayStatus = statuses.paused;
|
||||||
let isMutedArtist = true;
|
|
||||||
|
|
||||||
const elements = {
|
const elements = {
|
||||||
play: '*[data-test="play"]',
|
play: '*[data-test="play"]',
|
||||||
@ -329,7 +328,6 @@ setInterval(function () {
|
|||||||
const title = elements.getText("title");
|
const title = elements.getText("title");
|
||||||
const artists = elements.getArtists();
|
const artists = elements.getArtists();
|
||||||
skipArtistsIfFoundInSkippedArtistsList(artists);
|
skipArtistsIfFoundInSkippedArtistsList(artists);
|
||||||
muteArtistIfFoundInMutedArtistsList(artists); // doing this here so that nothing can possibly fail before we call this function
|
|
||||||
|
|
||||||
const album = elements.getAlbumName();
|
const album = elements.getAlbumName();
|
||||||
const current = elements.getText("current");
|
const current = elements.getText("current");
|
||||||
@ -381,24 +379,6 @@ setInterval(function () {
|
|||||||
() => {}
|
() => {}
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks whether the current artist is included in the "muted artists" list and if so it will automatically mute the player
|
|
||||||
*/
|
|
||||||
function muteArtistIfFoundInMutedArtistsList(artists) {
|
|
||||||
if (store.get(settings.muteArtists)) {
|
|
||||||
const mutedArtists = store.get(settings.mutedArtists);
|
|
||||||
if (mutedArtists.find((artist) => artist === artists) !== undefined) {
|
|
||||||
if (!elements.isMuted()) {
|
|
||||||
isMutedArtist = true;
|
|
||||||
elements.click("volume");
|
|
||||||
}
|
|
||||||
} else if (isMutedArtist && elements.isMuted()) {
|
|
||||||
elements.click("volume");
|
|
||||||
isMutedArtist = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* automatically skip a song if the artists are found in the list of artists to skip
|
* automatically skip a song if the artists are found in the list of artists to skip
|
||||||
* @param {*} artists list of artists to skip
|
* @param {*} artists list of artists to skip
|
||||||
|
@ -10,10 +10,9 @@ const store = new Store({
|
|||||||
notifications: true,
|
notifications: true,
|
||||||
api: true,
|
api: true,
|
||||||
playBackControl: true,
|
playBackControl: true,
|
||||||
muteArtists: false,
|
|
||||||
mutedArtists: ["TIDAL"],
|
|
||||||
skipArtists: false,
|
skipArtists: false,
|
||||||
skippedArtists: [""],
|
skippedArtists: [""],
|
||||||
|
adBlock: false,
|
||||||
disableBackgroundThrottle: true,
|
disableBackgroundThrottle: true,
|
||||||
menuBar: true,
|
menuBar: true,
|
||||||
apiSettings: {
|
apiSettings: {
|
||||||
|
Loading…
Reference in New Issue
Block a user