Update improved_redgifs.user.js
Partial rework to support the new RedGIFS layout.
This commit is contained in:
+51
-36
@@ -1,13 +1,13 @@
|
||||
// ==UserScript==
|
||||
// @name Improved RedGIFs
|
||||
// @namespace BigDuckie.ImprovedRedgifs
|
||||
// @version 2025.1.13
|
||||
// @description Fix a few annoying "features" and add an easy download button.
|
||||
// @version 2025.12.21
|
||||
// @description Fixes a few annoying "features" and add an easy download button.
|
||||
// @icon https://www.google.com/s2/favicons?sz=64&domain=redgifs.com
|
||||
// @author Big Duckie
|
||||
// @copyright 2025, Big Duckie (https://bigduckie.dev)
|
||||
// @license MIT
|
||||
// @match https://*.redgifs.com
|
||||
// @match https://*.redgifs.com/
|
||||
// @match https://*.redgifs.com/watch/*
|
||||
// @match https://*.redgifs.com/niches/*
|
||||
// @match https://*.redgifs.com/ifr/*
|
||||
@@ -20,7 +20,7 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
GM_addStyle(`
|
||||
.DLButton {
|
||||
.RGButton {
|
||||
background: 0 0;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
@@ -58,55 +58,68 @@
|
||||
stroke_linejoin: "round"
|
||||
}).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"))
|
||||
.attr({
|
||||
width: 24,
|
||||
height: 24,
|
||||
viewBox: "0 0 24 24",
|
||||
fill: "none",
|
||||
stroke: "currentColor",
|
||||
stroke_width: 2,
|
||||
stroke_linecap: "round",
|
||||
stroke_linejoin: "round"
|
||||
}).html(`<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line>`);
|
||||
const download_svg = () => jQuery(document.createElementNS("http://www.w3.org/2000/svg", "svg")).attr({
|
||||
width: 24,
|
||||
height: 24,
|
||||
viewBox: "0 0 24 24",
|
||||
fill: "none",
|
||||
stroke: "currentColor",
|
||||
stroke_width: 2,
|
||||
stroke_linecap: "round",
|
||||
stroke_linejoin: "round"
|
||||
}).html(`<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line>`);
|
||||
|
||||
// Remove overlayer
|
||||
jQuery.initialize(".Player-OverLayer", function() {
|
||||
jQuery.initialize(".Player-OverLayer", function () {
|
||||
this.remove();
|
||||
});
|
||||
|
||||
// Watch & Niche pages
|
||||
jQuery.initialize(".SideBar", function () {
|
||||
const gif_root = jQuery(this).parent().parent();
|
||||
let gif_id = gif_root.attr("id").substring(4);
|
||||
// --- Watch pages ---
|
||||
jQuery.initialize(".sideBar", async function () {
|
||||
const sidebar = jQuery(this);
|
||||
const root = sidebar.parents(".GifPreview");
|
||||
|
||||
jQuery(this).find(".SideBar-Item>.rg-button.views").on("click", function () {
|
||||
togglePlayer(gif_root.find(".Player-Video>video")[0]);
|
||||
}).children("svg").replaceWith(pause_svg());
|
||||
|
||||
jQuery(this).children(".SideBar-Item:has(.FSButton)").after(
|
||||
// Add play pause button
|
||||
sidebar.prepend(
|
||||
jQuery("<li>", {
|
||||
class: "SideBar-Item"
|
||||
class: "sideBarItem"
|
||||
}).append(
|
||||
jQuery("<button>", {
|
||||
class: "DLButton",
|
||||
"aria-label": "download video"
|
||||
}).append(download_svg()).on("click", () => {
|
||||
download(gif_id);
|
||||
class: "PPButton RGButton",
|
||||
"aria-label": "pause play button"
|
||||
}).append(pause_svg()).on("click", () => {
|
||||
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] });
|
||||
|
||||
// Add callback to change pause play button svg.
|
||||
jQuery.initialize(".Player-Video>video", function () {
|
||||
jQuery(this).on("play", function () {
|
||||
jQuery(this).parents(".GifPreview").find(".rg-button.views>svg").replaceWith(play_svg());
|
||||
const video = jQuery(this);
|
||||
const root = video.parents(".GifPreview");
|
||||
|
||||
video.on("play", function () {
|
||||
root.find(".PPButton>svg").replaceWith(play_svg());
|
||||
}).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] });
|
||||
// ---- Watch Pages ---
|
||||
|
||||
// IFR pages
|
||||
// IFR pages (Still needs rework)
|
||||
jQuery.initialize(".embeddedPlayer", function () {
|
||||
jQuery(this).children(".buttons").prepend(
|
||||
jQuery("<div>", {
|
||||
@@ -137,6 +150,8 @@
|
||||
});
|
||||
}, { target: jQuery(".embeddedPlayer")[0] });
|
||||
|
||||
// --- Helper Functions ---
|
||||
|
||||
async function togglePlayer(video) {
|
||||
video.paused ? video.play() : video.pause();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user