Skip to content

Commit 59f81f4

Browse files
committed
feat(full-screen): support GlobalNav TV mode button placement
1 parent 232b892 commit 59f81f4

File tree

5 files changed

+50
-27
lines changed

5 files changed

+50
-27
lines changed

Extensions/full-screen/dist/fullScreen.js

+15-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Extensions/full-screen/src/app.tsx

+27-8
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ import {
1515
import { headerText, getSettingCard, createAdjust, getAboutSection } from "./utils/setting";
1616

1717
import translations from "./resources/strings";
18-
import ICONS, { DEFAULTS, CLASSES_TO_ADD, EXTRA_BAR_SELECTOR, TOP_BAR_SELECTOR } from "./constants";
18+
import ICONS, {
19+
DEFAULTS,
20+
CLASSES_TO_ADD,
21+
EXTRA_BAR_SELECTOR,
22+
TOP_BAR_SELECTOR,
23+
TOP_BAR_SELECTOR_GLOBAL_NAVBAR,
24+
} from "./constants";
1925
import { Config, Settings } from "./types/fullscreen";
2026

2127
import WebAPI from "./services/web-api";
@@ -1634,19 +1640,32 @@ async function main() {
16341640
if (CFM.getGlobal("buttonActivation") !== "def") {
16351641
// Add TV Mode Button on top bar
16361642
const tvButton = document.createElement("button");
1637-
tvButton.classList.add(
1638-
"button",
1639-
"tm-button",
1640-
"main-topBar-button",
1641-
"InvalidDropTarget",
1642-
);
1643+
16431644
tvButton.innerHTML = ICONS.TV_MODE;
16441645
tvButton.id = "TV-button";
16451646
tvButton.setAttribute("title", translations[LOCALE].tvBtnDesc);
16461647

16471648
tvButton.onclick = openwithTV;
1649+
if (document.querySelector(TOP_BAR_SELECTOR)) {
1650+
tvButton.classList.add(
1651+
"button",
1652+
"tm-button",
1653+
"main-topBar-button",
1654+
"InvalidDropTarget",
1655+
);
1656+
document.querySelector(TOP_BAR_SELECTOR)?.append(tvButton);
1657+
} else {
1658+
tvButton.classList.add(
1659+
"tm-button",
1660+
"Button-small-small-buttonTertiary-condensedAll-isUsingKeyboard-useBrowserDefaultFocusStyle",
1661+
"encore-text-body-small-bold",
1662+
"main-globalNav-buddyFeed",
1663+
"Button-sc-1dqy6lx-0",
1664+
);
1665+
document.querySelector(TOP_BAR_SELECTOR_GLOBAL_NAVBAR)?.prepend(tvButton);
1666+
}
16481667

1649-
document.querySelector(TOP_BAR_SELECTOR)?.append(tvButton);
1668+
// document.querySelector(TOP_BAR_SELECTOR)?.append(tvButton);
16501669
tvButton.oncontextmenu = (evt) => {
16511670
evt.preventDefault();
16521671
CFM.setMode("tv");

Extensions/full-screen/src/constants/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import ICONS from "./icons";
22

33
export { DEFAULTS } from "./defaults";
44
export { CLASSES_TO_ADD } from "./general";
5-
export { TOP_BAR_SELECTOR, EXTRA_BAR_SELECTOR } from "./selectors";
5+
export { TOP_BAR_SELECTOR, EXTRA_BAR_SELECTOR, TOP_BAR_SELECTOR_GLOBAL_NAVBAR } from "./selectors";
66

77
export default ICONS;

Extensions/full-screen/src/constants/selectors.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export const TOP_BAR_SELECTOR = ".main-topBar-historyButtons";
2+
export const TOP_BAR_SELECTOR_GLOBAL_NAVBAR = ".main-topBar-topbarContentRight>.main-actionButtons";
23
export const EXTRA_BAR_SELECTOR = ".main-nowPlayingBar-right";
34
export const ORIGINAL_QUEUE_BUTTON =
45
"div.main-nowPlayingBar-right > div > div.GlueDropTarget.GlueDropTarget--tracks.GlueDropTarget--local-tracks.GlueDropTarget--episodes > button";

Extensions/full-screen/src/utils/utils.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import ICONS from "../constants";
22
import {
33
TOP_BAR_SELECTOR,
4+
TOP_BAR_SELECTOR_GLOBAL_NAVBAR,
45
EXTRA_BAR_SELECTOR,
56
ORIGINAL_QUEUE_BUTTON,
67
RIGH_PANEL,
@@ -15,11 +16,13 @@ let wasQueuePanelEnabled: boolean | null = null;
1516
class Utils {
1617
static allNotExist() {
1718
const extraBar = document.querySelector(EXTRA_BAR_SELECTOR)?.childNodes[0];
18-
const topBar = document.querySelector(TOP_BAR_SELECTOR);
19+
const topBar =
20+
document.querySelector(TOP_BAR_SELECTOR) ||
21+
document.querySelector(TOP_BAR_SELECTOR_GLOBAL_NAVBAR);
1922

2023
const entriesToVerify = {
21-
// "Top Bar Component": topBar,
22-
// "Extra Bar Component": extraBar,
24+
"Top Bar Component": topBar,
25+
"Extra Bar Component": extraBar,
2326
"Spicetify CosmosAsync": Spicetify.CosmosAsync,
2427
"Spicetify Mousetrap": Spicetify.Mousetrap,
2528
"Spicetify Player": Spicetify.Player,

0 commit comments

Comments
 (0)