Skip to content

Commit

Permalink
feat: store redgifs token to avoid hitting rate limit
Browse files Browse the repository at this point in the history
  • Loading branch information
yadue committed Jan 31, 2024
1 parent da441a8 commit 69cad8f
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions plugins/redgifs.js
Original file line number Diff line number Diff line change
@@ -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);
Expand Down

0 comments on commit 69cad8f

Please sign in to comment.