Skip to content

Commit

Permalink
Add fullscreen display for image expandos
Browse files Browse the repository at this point in the history
  • Loading branch information
OctoNezd committed Jun 8, 2023
1 parent b313593 commit 085c3fc
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
29 changes: 29 additions & 0 deletions css/resFullscreenGallery.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.res-gallery,
.imagePost
.res-expando-box:not([data-host="redditgallery"])
.res-expando-box-inner {
position: fixed;
top: 0;
left: 0;
height: 100vh;
width: 100%;
z-index: 200;
background-color: black;
color: white;
}
.expando-button.image.expanded {
position: fixed;
top: 25px;
right: 0;
z-index: 201;
width: 48px;
height: 48px;
}
.res-gallery-pieces,
.imagePost
.res-expando-box:not([data-host="redditgallery"])
.res-expando-box-inner {
flex-grow: 1;
display: flex !important;
align-items: center;
}
1 change: 1 addition & 0 deletions js/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ import "~/css/hideAds.css";
import "~/css/redditChanges.css";
import "~/css/customUi.css";
import "~/css/userTabIcons.css";
import "~/css/resFullscreenGallery.css";
console.log("Content script loaded.");
10 changes: 10 additions & 0 deletions js/posts/expando.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default function (post) {
const expando_btn = post.querySelector(".expando-button");
console.log(expando_btn.classList);
if (
expando_btn.classList.contains("image") ||
expando_btn.classList.contains("video")
) {
post.classList.add("imagePost");
}
}
28 changes: 28 additions & 0 deletions js/posts/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import setupNativeShare from "./nativeSharing.js";
import setupToggles from "./postToggles.js";
import expando from "./expando.js";
import "@fortawesome/fontawesome-free/js/all.js";
import "@fortawesome/fontawesome-free/css/all.css";
import "~/css/postIcons.css";
Expand All @@ -26,6 +27,33 @@ export default function setupPosts() {
comments.innerText = "0";
}
}
const expando_btn = post.querySelector(".expando-button");
if (expando_btn !== null) {
if (
expando_btn.getAttribute("title") === "Expando is not yet ready"
) {
const attrObserver = new MutationObserver((mutations) => {
mutations.forEach((mu) => {
if (
mu.type !== "attributes" &&
mu.attributeName !== "class"
)
return;
console.log("class was modified!");
expando(post);
attrObserver.disconnect();
});
});
console.log(
"Expando is not ready yet, setting up mutation observer for",
expando_btn
);
attrObserver.observe(expando_btn, { attributes: true });
} else {
expando(post);
}
}

// remove thumbnail no-image indicator. Could be done with CSS, but FF doesn't support :has.
const thumbnail = post.querySelector(".thumbnail");
if (thumbnail !== null && thumbnail.children.length === 0) {
Expand Down

0 comments on commit 085c3fc

Please sign in to comment.