Update improved_redgifs.user.js

Decided to complete the IFR page rework.
This commit is contained in:
2025-12-21 01:42:53 -07:00
parent 6a5cd17c07
commit e4eea9baec
+48 -25
View File
@@ -2,7 +2,7 @@
// @name Improved RedGIFs // @name Improved RedGIFs
// @namespace BigDuckie.ImprovedRedgifs // @namespace BigDuckie.ImprovedRedgifs
// @version 2025.12.21 // @version 2025.12.21
// @description Fixes a few annoying "features" and add an easy download button. // @description Fix a few annoying "features" and add an easy download button.
// @icon https://www.google.com/s2/favicons?sz=64&domain=redgifs.com // @icon https://www.google.com/s2/favicons?sz=64&domain=redgifs.com
// @author Big Duckie // @author Big Duckie
// @copyright 2025, Big Duckie (https://bigduckie.dev) // @copyright 2025, Big Duckie (https://bigduckie.dev)
@@ -74,8 +74,15 @@
this.remove(); this.remove();
}); });
// Remove videoLink href
jQuery.initialize(".videoLink", function() {
jQuery(this).removeAttr("href");
});
// --- Watch pages --- // --- Watch pages ---
jQuery.initialize(".sideBar", async function () { jQuery.initialize(".sideBar", async function () {
console.debug("detected watch page gif");
const sidebar = jQuery(this); const sidebar = jQuery(this);
const root = sidebar.parents(".GifPreview"); const root = sidebar.parents(".GifPreview");
@@ -117,38 +124,54 @@
root.find(".PPButton>svg").replaceWith(pause_svg()); root.find(".PPButton>svg").replaceWith(pause_svg());
}); });
}, { target: jQuery(".previewFeed")[0] }); }, { target: jQuery(".previewFeed")[0] });
// ---- Watch Pages --- // --- Watch Pages ---
// IFR pages (Still needs rework) // --- IFR Pages (Embedded) ---
jQuery.initialize(".embeddedPlayer", function () { jQuery.initialize(".sidebar", function () {
jQuery(this).children(".buttons").prepend( console.debug("detected embedded gif");
jQuery("<div>", {
class: "button"
}).append(
pause_svg().attr({ class: "playButton" })
).on("click", () => {
togglePlayer(jQuery(".videoLink>video")[0]);
})
)
jQuery(this).children(".buttons").append( const sidebar = jQuery(this);
jQuery("<div>", { const root = sidebar.parents(".embeddedPlayer");
class: "button"
// Add play pause button
sidebar.prepend(
jQuery("<li>", {
class: "item"
}).append( }).append(
download_svg() jQuery("<button>", {
).on("click", () => { class: "PPButton RGButton",
download(window.location.pathname.split("/")[2]) "aria-label": "pause play button"
}) }).append(pause_svg()).on("click", () => {
) togglePlayer(root.find(".videoLink>video")[0]);
})
));
// Add download button
sidebar.children(".item:has(.FSButton)").after(
jQuery("<li>", {
class: "item"
}).append(
jQuery("<button>", {
class: "DLButton RGButton",
"aria-label": "download button"
}).append(download_svg()).on("click", () => {
download(window.location.pathname.split("/")[2]);
})
));
}, { target: jQuery(".routeWrapper")[0] }); }, { target: jQuery(".routeWrapper")[0] });
// Add callback to change pause play button svg.
jQuery.initialize(".videoLink>video", function () { jQuery.initialize(".videoLink>video", function () {
jQuery(this).on("play", function () { const video = jQuery(this);
jQuery(this).parents(".embeddedPlayer").find("svg.playButton").replaceWith(play_svg().attr({ class: "playButton" })); const root = video.parents(".embeddedPlayer");
video.on("play", function () {
root.find(".PPButton>svg").replaceWith(play_svg());
}).on("pause", function () { }).on("pause", function () {
jQuery(this).parents(".embeddedPlayer").find("svg.playButton").replaceWith(pause_svg().attr({ class: "playButton" })); root.find(".PPButton>svg").replaceWith(pause_svg());
}); });
}, { target: jQuery(".embeddedPlayer")[0] }); }, { target: jQuery(".routeWrapper")[0] });
// --- IFR Pages ---
// --- Helper Functions --- // --- Helper Functions ---