Update improved_redgifs.user.js
Added check to make sure the token is valid. If not, refresh token.
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Improved RedGIFs
|
// @name Improved RedGIFs
|
||||||
// @namespace BigDuckie.ImprovedRedgifs
|
// @namespace BigDuckie.ImprovedRedgifs
|
||||||
// @version 2025.12.21
|
// @version 2025.12.22
|
||||||
// @description Fix 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
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
// @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/users/*
|
||||||
// @match https://*.redgifs.com/ifr/*
|
// @match https://*.redgifs.com/ifr/*
|
||||||
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js
|
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js
|
||||||
// @require https://raw.githubusercontent.com/pie6k/jquery.initialize/master/jquery.initialize.min.js
|
// @require https://raw.githubusercontent.com/pie6k/jquery.initialize/master/jquery.initialize.min.js
|
||||||
@@ -28,10 +29,6 @@
|
|||||||
font: var(--s1-medium);
|
font: var(--s1-medium);
|
||||||
text-shadow: var(--black) 1px 0 5px;
|
text-shadow: var(--black) 1px 0 5px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
|
||||||
|
|
||||||
.embeddedPlayer .buttons .button svg {
|
|
||||||
margin-left: 3px;
|
|
||||||
}`);
|
}`);
|
||||||
|
|
||||||
jQuery.noConflict();
|
jQuery.noConflict();
|
||||||
@@ -193,8 +190,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function download(id) {
|
async function download(id) {
|
||||||
let token = await getToken()
|
let token = await getToken();
|
||||||
let gif = await (await fetch(`https://api.redgifs.com/v2/gifs/${id}`, { headers: { Authorization: `Bearer ${token}` } })).json()
|
let resp = await fetch(`https://api.redgifs.com/v2/gifs/${id}`, { headers: { Authorization: `Bearer ${token}` } });
|
||||||
|
if (!resp.ok) {
|
||||||
|
localStorage.removeItem("userscript_access_token");
|
||||||
|
await download(id);
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let gif = await resp.json();
|
||||||
let url = gif.gif.urls.hd;
|
let url = gif.gif.urls.hd;
|
||||||
GM_download(url, url.split("/").pop().split("?")[0]);
|
GM_download(url, url.split("/").pop().split("?")[0]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user