Skip to content

Commit a13606b

Browse files
authored
Merge pull request #894 from MiepHD/master
Center toggle of video-toggle
2 parents d0ed649 + 2b8b825 commit a13606b

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed

plugins/video-toggle/button-switcher.css

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
align-items: unset !important;
33
}
44

5+
#main-panel {
6+
position: relative;
7+
}
8+
59
.video-switch-button {
610
z-index: 999;
711
box-sizing: border-box;
@@ -18,6 +22,7 @@
1822
color: #fff;
1923
padding-right: 120px;
2024
position: absolute;
25+
left: var(--align);
2126
}
2227

2328
.video-switch-button:before {

plugins/video-toggle/front.js

+16-1
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,29 @@ module.exports = (_options) => {
3131
document.addEventListener("apiLoaded", setup, { once: true, passive: true });
3232
}
3333
}
34+
const mainpanel = document.querySelector("#main-panel");
35+
switch (_options.align) {
36+
case "right": {
37+
mainpanel.style.setProperty("--align", "calc(100% - 240px)");
38+
return;
39+
}
40+
case "middle": {
41+
mainpanel.style.setProperty("--align", "calc(50% - 120px)");
42+
return;
43+
}
44+
default:
45+
case "left": {
46+
mainpanel.style.setProperty("--align", "0px");
47+
}
48+
}
3449
};
3550

3651
function setup(e) {
3752
api = e.detail;
3853
player = $('ytmusic-player');
3954
video = $('video');
4055

41-
$('ytmusic-player-page').prepend(switchButtonDiv);
56+
$('#main-panel').append(switchButtonDiv);
4257

4358
if (options.hideVideo) {
4459
$('.video-switch-button-checkbox').checked = false;

plugins/video-toggle/menu.js

+32
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,38 @@ module.exports = (win, options) => [
3333
},
3434
]
3535
},
36+
{
37+
label: "Alignment",
38+
submenu: [
39+
{
40+
label: "Left",
41+
type: "radio",
42+
checked: options.align === 'left',
43+
click: () => {
44+
options.align = 'left';
45+
setMenuOptions("video-toggle", options);
46+
}
47+
},
48+
{
49+
label: "Middle",
50+
type: "radio",
51+
checked: options.align === 'middle',
52+
click: () => {
53+
options.align = 'middle';
54+
setMenuOptions("video-toggle", options);
55+
}
56+
},
57+
{
58+
label: "Right",
59+
type: "radio",
60+
checked: options.align === 'right',
61+
click: () => {
62+
options.align = 'right';
63+
setMenuOptions("video-toggle", options);
64+
}
65+
},
66+
]
67+
},
3668
{
3769
label: "Force Remove Video Tab",
3870
type: "checkbox",

0 commit comments

Comments
 (0)