Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DEPRECATED] Local Subscriptions Plugin #340

Closed
wants to merge 730 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
730 commits
Select commit Hold shift + click to select a range
87a8fee
fix in-app-menu navbar opacity + scrollbar color
Araxeus Apr 3, 2021
2722ee2
Minimalize tray menu
Araxeus Apr 3, 2021
1a7ef11
remove redundant roles
Araxeus Apr 3, 2021
dae8ef0
additional cleanup/refactoring
semvis123 Apr 3, 2021
fd3b09e
Merge branch 'master' into lastfm
semvis123 Apr 3, 2021
8e46aaa
move advanced options to dedicated submenu +
Araxeus Apr 3, 2021
8e41e8e
fix bug when loading window with no connection
Araxeus Apr 3, 2021
416c28d
add 'electron-prompt' and use it for setting proxy
Araxeus Apr 3, 2021
c9773d9
fix memory leak +
Araxeus Apr 3, 2021
5cd3f5a
refactor and stylecheck
Araxeus Apr 3, 2021
f6739b1
fix in-app-menu hideMenu on launch
Araxeus Apr 3, 2021
a6b64cb
fix Connection Error when using in-app-menu
Araxeus Apr 3, 2021
73b7a39
Revert "fix Connection Error when using in-app-menu"
Araxeus Apr 3, 2021
3e29f1a
disable dev tools on electron-prompt
Araxeus Apr 3, 2021
1be3607
ignore proxy if equal to example
Araxeus Apr 3, 2021
22a504a
custom dark skin for prompt
Araxeus Apr 4, 2021
c7d7d03
implement custom prompt
Araxeus Apr 4, 2021
53cb739
css tweaks
Araxeus Apr 4, 2021
95ac788
stylecheck
Araxeus Apr 4, 2021
f6542d8
add back-to-front logger
Araxeus Apr 5, 2021
a88d213
stylecheck
Araxeus Apr 5, 2021
835a872
fix hide-menu timing + minify log function
Araxeus Apr 5, 2021
96a3f76
fix typo
Araxeus Apr 5, 2021
e40aef8
move prompt to provide
Araxeus Apr 5, 2021
7c9a656
Create readme.md
Araxeus Apr 5, 2021
73ad9b0
refactor and css fix
Araxeus Apr 5, 2021
a70e076
xo --fix
Araxeus Apr 5, 2021
470e707
add inline doc
Araxeus Apr 5, 2021
7ef5eb1
fix typo
Araxeus Apr 5, 2021
6b160f8
Create readme.md
Araxeus Apr 6, 2021
da9bcd4
Merge branch 'menu-fixes' of https://github.com/Araxeus/youtube-music…
Araxeus Apr 6, 2021
5f74452
add windows interactive notifications
Araxeus Apr 8, 2021
d376d62
remove appID because of bug:
Araxeus Apr 8, 2021
355ad16
stylecheck
Araxeus Apr 8, 2021
64fc00e
minify
Araxeus Apr 8, 2021
4272ff5
fix rare crash due to unfocus effect
Araxeus Apr 8, 2021
ae6ee3c
add note to notifications.interactive
Araxeus Apr 8, 2021
4643427
fix unPause option compatibility
Araxeus Apr 9, 2021
d476f03
clarify button purpose
Araxeus Apr 9, 2021
94c19b0
Center Icon on ALL notifications
Araxeus Apr 9, 2021
caa8b6c
change notification priority to show only on linux
Araxeus Apr 9, 2021
13c8c55
Revert "fix rare crash due to unfocus effect"
Araxeus Apr 9, 2021
ab5f3a8
add unresponsive listener
Araxeus Apr 9, 2021
dd49512
remove downloads-folder and use electron instead
Araxeus Apr 9, 2021
a3f3b02
update dependecies
Araxeus Apr 9, 2021
e01238f
taskbar-mediacontrol no longer override win.hide
Araxeus Apr 9, 2021
cc539d6
Update ytpl
Araxeus Apr 12, 2021
b3e3706
cleanup unresponsiveDialog
Araxeus Apr 14, 2021
4c08f26
remove " - Topic" from artist name
Araxeus Apr 14, 2021
300bc6a
navbar background black fix visual bug
Araxeus Apr 15, 2021
e02e345
fix unresponsive dialog response
Araxeus Apr 15, 2021
a964bcf
scrape artistName from playBar
Araxeus Apr 15, 2021
6216f38
fix: upgrade @cliqz/adblocker-electron from 1.20.3 to 1.20.4
snyk-bot Apr 16, 2021
11962ce
add precise scrollwheel control + precise tooltip
Araxeus Apr 16, 2021
0719e5e
update inline doc
Araxeus Apr 16, 2021
96aaf6a
xo --fix
Araxeus Apr 16, 2021
ff0fde6
refactor
Araxeus Apr 16, 2021
70cb69e
save volume to settings
Araxeus Apr 16, 2021
e9f59f9
fix set volume on first run after not using plugin
Araxeus Apr 16, 2021
2d59744
add optional arrowkeys controls option
Araxeus Apr 17, 2021
65eae2b
enable changing shortcut setting without restart
Araxeus Apr 17, 2021
e0ebab1
fix changing settings when plugin is disabled
Araxeus Apr 17, 2021
5e321e9
xo --fix
Araxeus Apr 17, 2021
44f7a41
add advanced option to change volume steps
Araxeus Apr 17, 2021
28a3aa0
add prompt with number counter
Araxeus Apr 17, 2021
46f2594
lint
Araxeus Apr 17, 2021
7aaff6c
xo --fix
Araxeus Apr 17, 2021
9056e91
add rapidFire option to counter prompt
Araxeus Apr 17, 2021
5f593be
use timeout ID to stop callback
Araxeus Apr 17, 2021
ddeabb3
lint
Araxeus Apr 17, 2021
8ecec8e
refactor + lint
Araxeus Apr 18, 2021
7f838f8
add option for plugin to have a preload.js
Araxeus Apr 22, 2021
fa97953
disable native volume-slider listeners
Araxeus Apr 22, 2021
199af16
Show volume slider on volume change
Araxeus Apr 22, 2021
eb43514
lint
Araxeus Apr 22, 2021
0dec12a
remove slider on-hover after 3 seconds if !focused
Araxeus Apr 22, 2021
f5434d5
simple fix
Araxeus Apr 23, 2021
5f286aa
revert to original lint format
Araxeus Apr 23, 2021
79cb444
`once` instead of `on`
Araxeus Apr 23, 2021
4b79a21
`win.once()` instead of `win.on`
Araxeus Apr 23, 2021
1bd27d5
Update readme.md
Araxeus Apr 23, 2021
03e1840
Add Video Player Mousewheel Volume Control
Araxeus Apr 23, 2021
392bc64
addEventListener insead of .onwheel
Araxeus Apr 24, 2021
d901a4b
enable global volume shortcuts in advanced config
Araxeus Apr 26, 2021
6cda4ca
update inline doc
Araxeus Apr 26, 2021
dda0d7d
Merge pull request #239 from Araxeus/discord-fix
th-ch Apr 27, 2021
0d2429a
implement keybind prompt
Araxeus Apr 27, 2021
2610044
defensive code
Araxeus Apr 27, 2021
5c6f309
switch function name to camelCase
Araxeus Apr 27, 2021
38f496d
remove local prompt
Araxeus Apr 27, 2021
b585c1a
leave debug for next PR
Araxeus Apr 28, 2021
3eb492b
fix typo
Araxeus Apr 28, 2021
fbca6d6
remove proxy from menu
Araxeus Apr 28, 2021
9d22df3
update camelCase
Araxeus Apr 28, 2021
f7b6fd7
make variable names clearer
Araxeus Apr 28, 2021
6810679
fix typo
Araxeus Apr 28, 2021
ccd390b
fix typo
Araxeus Apr 28, 2021
9f6bee5
small refactor
Araxeus Apr 28, 2021
d185537
Merge pull request #196 from semvis123/lastfm
th-ch Apr 28, 2021
4bdf7e1
Update yarn.lock
th-ch Apr 28, 2021
3e494a9
fix: upgrade electron-store from 7.0.2 to 7.0.3
snyk-bot Apr 29, 2021
19edb54
Fix download URL
th-ch Apr 29, 2021
8f89fe7
Set max file length to 255 in downloader
th-ch Apr 29, 2021
883e61f
Set metadata in back (to have cover)
th-ch Apr 29, 2021
bd0ba3d
Merge pull request #245 from th-ch/fix-downloader-metadata
th-ch Apr 29, 2021
4a443cd
Merge branch 'master' into dependencies-update
th-ch Apr 29, 2021
73bc6a4
Merge pull request #231 from Araxeus/dependencies-update
th-ch Apr 29, 2021
fbcb558
Fix getFolder util (main/renderer process)
th-ch Apr 29, 2021
76e09a7
Merge pull request #233 from th-ch/snyk-upgrade-db0717b422c1c3d1fcb50…
th-ch Apr 29, 2021
b0536d4
Merge pull request #244 from th-ch/snyk-upgrade-99aee86a0f7b96c0f871b…
th-ch Apr 29, 2021
914c909
Merge pull request #236 from Araxeus/precise-volume
th-ch May 2, 2021
a476274
Merge branch 'master' into interactive-notifications
th-ch May 2, 2021
e46032c
remove redundant dialog import
Araxeus May 2, 2021
3bde726
minify switch case
Araxeus May 2, 2021
46fcb29
fix typo
Araxeus May 2, 2021
fa28737
Merge branch 'menu-fixes' of https://github.com/Araxeus/youtube-music…
Araxeus May 2, 2021
bf8ef75
Merge pull request #228 from Araxeus/interactive-notifications
th-ch May 2, 2021
1d91187
Fix package.json indent, update yarn.lock
th-ch May 2, 2021
452062a
resolve merge conflict
Araxeus May 2, 2021
515cfb9
Update electron to 11.4.4
th-ch May 2, 2021
ab1a1e6
Bump version to 1.12.0
th-ch May 3, 2021
3f530de
stringify did-fail-load error
Araxeus May 3, 2021
d3584f5
ignore did-fail-load error code `-3`
Araxeus May 3, 2021
44d4dcd
Merge pull request #224 from Araxeus/menu-fixes
th-ch May 4, 2021
dc4b54d
Remove preload.js in plugin uses and use front plugin injection
th-ch May 4, 2021
d0c2444
Import front logger at top level
th-ch May 4, 2021
b0242aa
Revert "Remove preload.js in plugin uses and use front plugin injection"
th-ch May 4, 2021
c59e044
fix metadata when downloading unplayed song
Araxeus May 5, 2021
c7bd71b
use media propery if exist in song-info
Araxeus May 5, 2021
f3943ab
lint
Araxeus May 5, 2021
ea6533d
allow unlimited playlist size
Araxeus May 5, 2021
7d29e4b
fix error thrown when downloading playlist
Araxeus May 5, 2021
7dd4344
custom metadata on playlist-download
Araxeus May 6, 2021
347ba76
started playlist downlaod messageBox
Araxeus May 6, 2021
9339a41
playlist download progressBar using `chokidar`
Araxeus May 6, 2021
bfe6377
lint
Araxeus May 6, 2021
2964cea
fix listener override condition
Araxeus May 6, 2021
7e551d9
fix `preventDefault()` being called on *all* keys
Araxeus May 6, 2021
7dc924e
refactor addEventListener
Araxeus May 6, 2021
994d983
lint
Araxeus May 6, 2021
64e5210
fix css not inserting on reload
Araxeus May 6, 2021
96d0383
directly playPause video element
Araxeus May 6, 2021
0a92d26
lint
Araxeus May 6, 2021
3ee04fc
minify
Araxeus May 6, 2021
324898c
Merge pull request #255 from Araxeus/fix-css-on-reload
th-ch May 6, 2021
ff2cdc8
Bump ua-parser-js from 0.7.23 to 0.7.28
dependabot[bot] May 6, 2021
adefc7f
Merge pull request #253 from Araxeus/fix-precise-volume-listener-over…
th-ch May 6, 2021
bb8cd1b
Merge pull request #260 from th-ch/dependabot/npm_and_yarn/ua-parser-…
th-ch May 6, 2021
b76b907
Bump version to 1.12.1
th-ch May 6, 2021
2530344
check if `yns_pause` exists
Araxeus May 7, 2021
bdb8b4e
create `cleanupArtistName()` in song-info
Araxeus May 7, 2021
39fd299
lint
Araxeus May 7, 2021
e573dee
Merge pull request #259 from Araxeus/force-pause
th-ch May 7, 2021
b4175d6
Add `start:debug` command to enable dev with electron debug
th-ch May 7, 2021
4acf643
lint
Araxeus May 7, 2021
6208a02
Merge pull request #252 from Araxeus/fix-download-idtag-if-not-playing
th-ch May 7, 2021
d172d9d
remove `open` dependency
Araxeus May 7, 2021
2bda7c2
lint
Araxeus May 7, 2021
664dd03
debug videoUrl from `start Radio` button in menu
Araxeus May 8, 2021
effd70d
use image from imageSrc if transfered
Araxeus May 8, 2021
a45700a
download progress bar on taskbar
Araxeus May 8, 2021
90db937
refactor
Araxeus May 8, 2021
19f7221
use original metadata only if not already captured from ytpl.getInfo()
Araxeus May 8, 2021
ec8bf7b
small refactor
Araxeus May 8, 2021
1628918
fix sendError()
Araxeus May 8, 2021
c219d71
differentiate names of different metadata sources
Araxeus May 8, 2021
aa58ac1
minimize getArtist()
Araxeus May 8, 2021
cb401e7
remove videoDetails?.media query from XHR
Araxeus May 8, 2021
dab1628
lint
Araxeus May 8, 2021
8fe1522
Merge pull request #262 from Araxeus/remove-`open`-dependency
th-ch May 8, 2021
9e63d92
lint
Araxeus May 8, 2021
f2f99d1
update radioButton querySelector
Araxeus May 8, 2021
793bf6d
querySelector optimization #2
Araxeus May 8, 2021
795456c
Merge pull request #265 from Araxeus/ensure-download-from-radio-button
th-ch May 8, 2021
28c8e74
Downloader: catch error when fetching playlist
th-ch May 8, 2021
c209e2d
Downloader: rename UrlToJPG to urlToJPG
th-ch May 8, 2021
a68f0b6
fix config overwrite on each start
Araxeus May 9, 2021
f26b96d
Merge pull request #267 from Araxeus/last-fm-config-check-fix
th-ch May 9, 2021
26e45c4
setup SongInfo **once**
Araxeus May 10, 2021
d7d6353
refactor notifications plugin
Araxeus May 10, 2021
b129957
lint
Araxeus May 10, 2021
74aa6ff
set appID on windows
Araxeus May 10, 2021
c62ec8d
writeShortcut on windows
Araxeus May 10, 2021
eb59056
create shortcut only if needed
Araxeus May 10, 2021
76aa129
lint
Araxeus May 10, 2021
fd211cf
check that app is installed / unpacked
Araxeus May 10, 2021
9231543
register appID on windows reguardless of shortcut
Araxeus May 10, 2021
4ccc776
lint
Araxeus May 11, 2021
45745b5
Upgrade electron to v12
th-ch May 11, 2021
d97491e
Merge pull request #273 from th-ch/upgrade-electron
th-ch May 16, 2021
7a04172
Merge pull request #270 from Araxeus/fix-normal-notification-showing-…
th-ch May 16, 2021
ff3efe1
fix: upgrade ytpl from 2.1.1 to 2.2.0
snyk-bot May 17, 2021
5e287e0
switch to `registerCallback()` on song info
Araxeus May 18, 2021
2c9959a
fix: upgrade filenamify from 4.2.0 to 4.3.0
snyk-bot May 19, 2021
6356bce
fix notificationOnUnpause option
Araxeus May 22, 2021
deea422
fix: upgrade @ffmpeg/core from 0.8.5 to 0.9.0
snyk-bot May 26, 2021
2629e6c
fix: upgrade ytdl-core from 4.5.0 to 4.7.0
snyk-bot May 26, 2021
9f1498d
fix: upgrade @cliqz/adblocker-electron from 1.20.4 to 1.20.5
snyk-bot May 26, 2021
d8f1c68
Bump browserslist from 4.16.3 to 4.16.6
dependabot[bot] May 27, 2021
d05ca1d
Bump electron to 12.0.8
th-ch May 28, 2021
c758485
Merge pull request #269 from Araxeus/fix-XHR-duplicate-callback
th-ch May 28, 2021
58d68a9
Merge pull request #285 from th-ch/snyk-upgrade-7b9c569f5bdd092f76adf…
th-ch May 28, 2021
42e55ec
Merge pull request #293 from th-ch/snyk-upgrade-335ec370c7caa5a759c54…
th-ch May 28, 2021
790d9fb
Merge pull request #298 from th-ch/snyk-upgrade-d305cdce94133f6db9615…
th-ch May 28, 2021
24d25a0
Merge branch 'master' of github.com:th-ch/youtube-music into snyk-upg…
th-ch May 28, 2021
75464c9
Merge pull request #299 from th-ch/snyk-upgrade-37e43892f5a34f935e848…
th-ch May 28, 2021
5774e34
Merge branch 'master' of github.com:th-ch/youtube-music into snyk-upg…
th-ch May 28, 2021
b3b1545
Merge pull request #300 from th-ch/snyk-upgrade-ce2777733d9dee231391c…
th-ch May 28, 2021
47d8f2d
Merge pull request #301 from th-ch/dependabot/npm_and_yarn/browsersli…
th-ch May 28, 2021
03610ff
Bump ws from 7.4.3 to 7.4.6
dependabot[bot] May 28, 2021
b63b51d
Merge pull request #303 from th-ch/dependabot/npm_and_yarn/ws-7.4.6
th-ch May 28, 2021
ae70f00
fix: upgrade @ffmpeg/ffmpeg from 0.9.7 to 0.9.8
snyk-bot May 29, 2021
d4a1c07
Merge pull request #305 from th-ch/snyk-upgrade-15656c519a90f5bc0f5c8…
th-ch May 31, 2021
fcd8876
Set test environment per test file
th-ch Jun 3, 2021
057b88e
Refactor videoElement getter into a provider with callback
th-ch Jun 3, 2021
78f0d08
Add SponsorBlock plugin
th-ch Jun 3, 2021
9a68e14
Update adblocking
th-ch Jun 3, 2021
4e3ed42
Keep segments when skipping
th-ch Jun 3, 2021
b268f85
Merge pull request #308 from th-ch/sponsorblock-plugin
th-ch Jun 4, 2021
f6c7f07
fix: upgrade custom-electron-titlebar from 3.2.6 to 3.2.7
snyk-bot Jun 5, 2021
f99f52e
fix: upgrade @ffmpeg/ffmpeg from 0.9.8 to 0.10.0
snyk-bot Jun 8, 2021
a2198e1
fix: upgrade @ffmpeg/core from 0.9.0 to 0.10.0
snyk-bot Jun 8, 2021
0c297d1
fix unsupported hidden webp coverart
Araxeus Jun 9, 2021
aeb315c
check if native image is empty before writing id tag
Araxeus Jun 9, 2021
ac3dada
Bump trim-newlines from 3.0.0 to 3.0.1
dependabot[bot] Jun 9, 2021
1498027
Bump normalize-url from 4.5.0 to 4.5.1
dependabot[bot] Jun 11, 2021
07532f7
fix: upgrade electron-updater from 4.3.8 to 4.3.9
snyk-bot Jun 12, 2021
d271368
fix: upgrade ytdl-core from 4.8.0 to 4.8.2
snyk-bot Jun 19, 2021
da3b1c5
Merge pull request #318 from Araxeus/fix-hidden-webp-cover-art
th-ch Jun 19, 2021
e2e42f5
Bump hosted-git-info from 2.8.8 to 2.8.9
dependabot[bot] Jun 19, 2021
12afd3d
Merge pull request #311 from th-ch/snyk-upgrade-44a5db26689d4091f6a2c…
th-ch Jun 24, 2021
791e1e0
Merge pull request #316 from th-ch/snyk-upgrade-6e93904bf885d198521c6…
th-ch Jun 24, 2021
c092c39
Merge branch 'master' of github.com:th-ch/youtube-music into snyk-upg…
th-ch Jun 24, 2021
daa3163
Merge pull request #317 from th-ch/snyk-upgrade-a785f5d95c7765e2d4773…
th-ch Jun 24, 2021
bacc856
Merge pull request #320 from th-ch/dependabot/npm_and_yarn/trim-newli…
th-ch Jun 24, 2021
21b8ad1
Merge pull request #323 from th-ch/dependabot/npm_and_yarn/normalize-…
th-ch Jun 24, 2021
e3f879b
Merge pull request #324 from th-ch/snyk-upgrade-f650e2139b30a36951a4a…
th-ch Jun 24, 2021
ade06fd
Merge pull request #328 from th-ch/snyk-upgrade-dacfb8f0b574367961e40…
th-ch Jun 24, 2021
f570145
Bump lodash from 4.17.20 to 4.17.21
dependabot[bot] Jun 24, 2021
b1fae7a
Merge pull request #330 from th-ch/dependabot/npm_and_yarn/lodash-4.1…
th-ch Jun 24, 2021
385bbfd
Merge pull request #331 from th-ch/dependabot/npm_and_yarn/hosted-git…
th-ch Jun 24, 2021
d901c0a
init plugin
fdr-smnv Jun 25, 2021
c375d60
Refactor html & css, prepare front for sub button
fdr-smnv Jun 25, 2021
b08a7fc
Fix plugin menu error
fdr-smnv Jun 26, 2021
1bd2be2
Add working sub btn. Save subs in plugin options
fdr-smnv Jun 26, 2021
803facd
Render subs in new win On clk follow link Refactor
fdr-smnv Jun 27, 2021
9bd5489
Add comments
fdr-smnv Jun 27, 2021
d2b5074
Merge branch 'master' of github.com:fdr-smnv/youtube-music into local…
fdr-smnv Jun 27, 2021
b5dc5f4
Refactor
fdr-smnv Jun 27, 2021
4f8c228
Add default options for plugin
fdr-smnv Jun 27, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ const defaultConfig = {
"music_offtopic",
],
},
"local-subscriptions": {
enabled: false,
subscriptions: {}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That will require a store migration: when you enable it for the first time, your config will end up with:

local-subscriptions": {
  enabled: true
}

And the code does not support empty subscriptions :)

}
},
};

Expand Down
24 changes: 24 additions & 0 deletions plugins/local-subscriptions/actions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const { triggerAction } = require("../utils");

const CHANNEL = 'local-subscriptions'
const ACTIONS = {
SUBS_WIN_BTN: 'subscriptions-window-button',
SUBS_LI_CLK: 'subscriptions-list-item-click'
}

function openSubscriptionsWindow() {
triggerAction(CHANNEL, ACTIONS.SUBS_WIN_BTN)
}

function handleListItemClick(pathname) {
triggerAction(CHANNEL, ACTIONS.SUBS_LI_CLK, pathname)
}

module.exports = {
CHANNEL,
ACTIONS,
actions: {
openSubscriptionsWindow,
handleListItemClick
}
};
57 changes: 57 additions & 0 deletions plugins/local-subscriptions/back.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
const { BrowserWindow, ipcMain } = require("electron");
const path = require("path");
const defaultConfig = require("../../config/defaults");
const { getOptions, setOptions } = require("../../config/plugins");

const { injectCSS, listenAction, templatePath } = require("../utils");
const { ACTIONS, CHANNEL } = require("./actions.js");

let subscriptionsWindow;

module.exports = win => {
// inject CSS in main window
injectCSS(win.webContents, path.join(__dirname, "style.css"), () => {
win.webContents.send("subscriptions-css-ready");
});

listenAction(CHANNEL, (event, action, data) => {
switch(action) {
// Open new window and send there local subscriptions from options
case ACTIONS.SUBS_WIN_BTN:
subscriptionsWindow = new BrowserWindow({
parent: win,
webPreferences: {
preload: path.join(__dirname, "popup.js"),
affinity: "main-window"
}})
subscriptionsWindow.loadFile(templatePath(__dirname, "subscriptions-menu.html"))
subscriptionsWindow.webContents.on('did-stop-loading', () => subscriptionsWindow.webContents.send('saved-subscriptions', getOptions('local-subscriptions').subscriptions))
break;
case ACTIONS.SUBS_LI_CLK:
subscriptionsWindow.close();
console.log(action)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: only log that in dev mode (if is.dev())

win.loadURL(defaultConfig.url + data);
break;
default:
console.log("Unknown action: " + action);
}
})

// Handles sub button click and saves changes in options
ipcMain.on('sub-btn-clk', (event, pathname, channelName) => {
const currentSubscriptions = getOptions('local-subscriptions');
const newSubscription = {[pathname]: {channelName, subDate: new Date()}}
const didSubscribe = !!currentSubscriptions.subscriptions[pathname];

if (didSubscribe) {
delete currentSubscriptions.subscriptions[pathname];
setOptions('local-subscriptions', {...currentSubscriptions})
} else {
setOptions('local-subscriptions', {...currentSubscriptions,
subscriptions: {...currentSubscriptions.subscriptions, ...newSubscription}});
}
})

win.webContents.on('did-stop-loading', () => win.webContents.send('subscriptions-page-stop-loading'))
win.webContents.on('did-navigate-in-page', () => win.webContents.send('subscriptions-location-change'));
};
36 changes: 36 additions & 0 deletions plugins/local-subscriptions/front.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const { ipcRenderer } = require("electron");
const { ElementFromFile, templatePath } = require("../utils");

// Send channel data to 'back' on 'sub-btn-clk' channel
const localSubscriptionButtonHandler = () => {
const channelName = document.querySelector('.title.style-scope.ytmusic-immersive-header-renderer').innerHTML
ipcRenderer.send('sub-btn-clk', window.location.pathname, channelName);
}

module.exports = () => {
// On css load add local subscriptions button to the menu
ipcRenderer.on('subscriptions-css-ready', () => {
const localSubscriptionsButton = ElementFromFile(templatePath(__dirname, "subscriptions-tab.html"));
const menu = document.querySelector("ytmusic-pivot-bar-renderer");

if (menu) {
menu.appendChild(localSubscriptionsButton);
}
});

// On page loading finnish check if it is a channel page
// If it is add sub button to the page
ipcRenderer.on('subscriptions-page-stop-loading', () => {
const isChannelPage = window.location.pathname.includes('channel');

if (isChannelPage) {
const buttons = document.querySelector(".buttons.style-scope.ytmusic-immersive-header-renderer");
if (buttons) {
const localSubscriptionButton = document.createElement('button')
localSubscriptionButton.innerText = 'Local Subscription'
localSubscriptionButton.onclick = localSubscriptionButtonHandler;
buttons.appendChild(localSubscriptionButton);
}
}
});
};
31 changes: 31 additions & 0 deletions plugins/local-subscriptions/popup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const { ipcRenderer, contextBridge } = require("electron");
const { ElementFromHtml } = require("../utils");
const {handleListItemClick} =require('./actions').actions;


// Couldn't manage to attach actions to global object
// Only contextBridge have worked

// const actions = require('./actions.js').actions || {};
// Object.keys(actions).forEach((actionName) => {
// console.log(actionName);
// globalThis.API = {};
// globalThis.API[actionName] = actions[actionName];
// })

contextBridge.exposeInMainWorld('SUBS_WIN', {
handleListItemClick
})

// Load subscriptions in a list on window load
ipcRenderer.on('saved-subscriptions', (evt, subs) => {
const subList = document.getElementById('subscriptions-list');

if (subList) {
Object.keys(subs).forEach(subKey => {
const sub = subs[subKey];
const subEl = ElementFromHtml(`<li data-pathname="${subKey}" onclick="window.SUBS_WIN.handleListItemClick('${subKey}')">${sub.channelName} | ${sub.subDate}</a></li>`);
subList.appendChild(subEl);
})
}
})
19 changes: 19 additions & 0 deletions plugins/local-subscriptions/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.subscriptions-item {
font-family: Roboto, Noto Naskh Arabic UI, Arial, sans-serif;
font-size: 20px;
line-height: var(--ytmusic-title-1_-_line-height);
font-weight: 500;
color: #fff;
--yt-endpoint-color: #fff;
--yt-endpoint-hover-color: #fff;
--yt-endpoint-visited-color: #fff;
display: inline-flex;
align-items: center;
color: rgba(255, 255, 255, 0.5);
cursor: pointer;
margin: 0 var(--ytmusic-pivot-bar-tab-margin);
}

.subscriptions-item:hover {
color: #fff;
}
12 changes: 12 additions & 0 deletions plugins/local-subscriptions/templates/subscriptions-menu.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Subscriptions</title>
</head>
<body>
<ul id='subscriptions-list'></ul>
</body>
</html>
16 changes: 16 additions & 0 deletions plugins/local-subscriptions/templates/subscriptions-tab.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<div
class="style-scope ytmusic-pivot-bar-renderer subscriptions-item"
tab-id="FElocal_subscriptions"
role="tab"
onclick="openSubscriptionsWindow()"
>
<div
class="search-icon style-scope ytmusic-search-box"
role="button"
tabindex="0"
aria-disabled="false"
title="Subscriptions"
>
<a class="tab-title style-scope ytmusic-pivot-bar-item-renderer">Subscriptions</a>
</div>
</div>