From 69cad8fde85c97d455b9a403561b986c8129b63c Mon Sep 17 00:00:00 2001 From: yadue Date: Wed, 31 Jan 2024 09:02:16 +0100 Subject: [PATCH] feat: store redgifs token to avoid hitting rate limit --- plugins/redgifs.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/plugins/redgifs.js b/plugins/redgifs.js index 1544bc947..f553d22d3 100644 --- a/plugins/redgifs.js +++ b/plugins/redgifs.js @@ -1,19 +1,21 @@ var hoverZoomPlugins = hoverZoomPlugins || []; +var tempToken; + hoverZoomPlugins.push({ name:'redgifs.com', version:'0.4', prepareImgLinks:function (callback) { var res = []; var name = this.name; - var apiUrl = 'https://api.redgifs.com/v2'; - var tempToken; - $.get(`${apiUrl}/auth/temporary`, function(data) { - if (data && data.token) { - tempToken = data.token; - } - }); + if (!tempToken) { + $.get(`${apiUrl}/auth/temporary`, function(data) { + if (data && data.token) { + tempToken = data.token; + } + }); + } $('a[href*="redgifs.com/"]').one('mouseenter', function () { const link = $(this);