Update improved_redgifs.user.js
Partial rework to support the new RedGIFS layout.
This commit is contained in:
+41
-26
@@ -1,13 +1,13 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Improved RedGIFs
|
// @name Improved RedGIFs
|
||||||
// @namespace BigDuckie.ImprovedRedgifs
|
// @namespace BigDuckie.ImprovedRedgifs
|
||||||
// @version 2025.1.13
|
// @version 2025.12.21
|
||||||
// @description Fix a few annoying "features" and add an easy download button.
|
// @description Fixes 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)
|
||||||
// @license MIT
|
// @license MIT
|
||||||
// @match https://*.redgifs.com
|
// @match https://*.redgifs.com/
|
||||||
// @match https://*.redgifs.com/watch/*
|
// @match https://*.redgifs.com/watch/*
|
||||||
// @match https://*.redgifs.com/niches/*
|
// @match https://*.redgifs.com/niches/*
|
||||||
// @match https://*.redgifs.com/ifr/*
|
// @match https://*.redgifs.com/ifr/*
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
GM_addStyle(`
|
GM_addStyle(`
|
||||||
.DLButton {
|
.RGButton {
|
||||||
background: 0 0;
|
background: 0 0;
|
||||||
border: none;
|
border: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
@@ -58,8 +58,7 @@
|
|||||||
stroke_linejoin: "round"
|
stroke_linejoin: "round"
|
||||||
}).html(`<rect x="6" y="4" width="4" height="16"></rect><rect x="14" y="4" width="4" height="16"></rect>`);
|
}).html(`<rect x="6" y="4" width="4" height="16"></rect><rect x="14" y="4" width="4" height="16"></rect>`);
|
||||||
|
|
||||||
const download_svg = () => jQuery(document.createElementNS("http://www.w3.org/2000/svg", "svg"))
|
const download_svg = () => jQuery(document.createElementNS("http://www.w3.org/2000/svg", "svg")).attr({
|
||||||
.attr({
|
|
||||||
width: 24,
|
width: 24,
|
||||||
height: 24,
|
height: 24,
|
||||||
viewBox: "0 0 24 24",
|
viewBox: "0 0 24 24",
|
||||||
@@ -75,38 +74,52 @@
|
|||||||
this.remove();
|
this.remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Watch & Niche pages
|
// --- Watch pages ---
|
||||||
jQuery.initialize(".SideBar", function () {
|
jQuery.initialize(".sideBar", async function () {
|
||||||
const gif_root = jQuery(this).parent().parent();
|
const sidebar = jQuery(this);
|
||||||
let gif_id = gif_root.attr("id").substring(4);
|
const root = sidebar.parents(".GifPreview");
|
||||||
|
|
||||||
jQuery(this).find(".SideBar-Item>.rg-button.views").on("click", function () {
|
// Add play pause button
|
||||||
togglePlayer(gif_root.find(".Player-Video>video")[0]);
|
sidebar.prepend(
|
||||||
}).children("svg").replaceWith(pause_svg());
|
|
||||||
|
|
||||||
jQuery(this).children(".SideBar-Item:has(.FSButton)").after(
|
|
||||||
jQuery("<li>", {
|
jQuery("<li>", {
|
||||||
class: "SideBar-Item"
|
class: "sideBarItem"
|
||||||
}).append(
|
}).append(
|
||||||
jQuery("<button>", {
|
jQuery("<button>", {
|
||||||
class: "DLButton",
|
class: "PPButton RGButton",
|
||||||
"aria-label": "download video"
|
"aria-label": "pause play button"
|
||||||
}).append(download_svg()).on("click", () => {
|
}).append(pause_svg()).on("click", () => {
|
||||||
download(gif_id);
|
togglePlayer(root.find(".Player-Video>video")[0]);
|
||||||
})
|
})
|
||||||
)
|
));
|
||||||
);
|
|
||||||
|
// Add download button
|
||||||
|
sidebar.children(".sideBarItem:has(.FSButton)").after(
|
||||||
|
jQuery("<li>", {
|
||||||
|
class: "sideBarItem"
|
||||||
|
}).append(
|
||||||
|
jQuery("<button>", {
|
||||||
|
class: "DLButton RGButton",
|
||||||
|
"aria-label": "download button"
|
||||||
|
}).append(download_svg()).on("click", () => {
|
||||||
|
download(root.attr("data-feed-item-id"));
|
||||||
|
})
|
||||||
|
));
|
||||||
}, { target: jQuery(".previewFeed")[0] });
|
}, { target: jQuery(".previewFeed")[0] });
|
||||||
|
|
||||||
|
// Add callback to change pause play button svg.
|
||||||
jQuery.initialize(".Player-Video>video", function () {
|
jQuery.initialize(".Player-Video>video", function () {
|
||||||
jQuery(this).on("play", function () {
|
const video = jQuery(this);
|
||||||
jQuery(this).parents(".GifPreview").find(".rg-button.views>svg").replaceWith(play_svg());
|
const root = video.parents(".GifPreview");
|
||||||
|
|
||||||
|
video.on("play", function () {
|
||||||
|
root.find(".PPButton>svg").replaceWith(play_svg());
|
||||||
}).on("pause", function () {
|
}).on("pause", function () {
|
||||||
jQuery(this).parents(".GifPreview").find(".rg-button.views>svg").replaceWith(pause_svg());
|
root.find(".PPButton>svg").replaceWith(pause_svg());
|
||||||
});
|
});
|
||||||
}, { target: jQuery(".previewFeed")[0] });
|
}, { target: jQuery(".previewFeed")[0] });
|
||||||
|
// ---- Watch Pages ---
|
||||||
|
|
||||||
// IFR pages
|
// IFR pages (Still needs rework)
|
||||||
jQuery.initialize(".embeddedPlayer", function () {
|
jQuery.initialize(".embeddedPlayer", function () {
|
||||||
jQuery(this).children(".buttons").prepend(
|
jQuery(this).children(".buttons").prepend(
|
||||||
jQuery("<div>", {
|
jQuery("<div>", {
|
||||||
@@ -137,6 +150,8 @@
|
|||||||
});
|
});
|
||||||
}, { target: jQuery(".embeddedPlayer")[0] });
|
}, { target: jQuery(".embeddedPlayer")[0] });
|
||||||
|
|
||||||
|
// --- Helper Functions ---
|
||||||
|
|
||||||
async function togglePlayer(video) {
|
async function togglePlayer(video) {
|
||||||
video.paused ? video.play() : video.pause();
|
video.paused ? video.play() : video.pause();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user