Skip to content

Commit

Permalink
remove redgifs referer header to make it work again (#1407)
Browse files Browse the repository at this point in the history
Co-authored-by: yadue <[email protected]>
  • Loading branch information
yadue and yadue authored Sep 3, 2024
1 parent 51e85e7 commit 8998271
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions plugins/redgifs.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var hoverZoomPlugins = hoverZoomPlugins || [];
hoverZoomPlugins.push({
name:'redgifs.com',
version:'0.4',
prepareImgLinks:function (callback) {
name: 'redgifs.com',
version: '0.4',
prepareImgLinks: function(callback) {
var self = this;
var res = [];
var name = this.name;
Expand All @@ -16,7 +16,21 @@ hoverZoomPlugins.push({
});
}

$('a[href*="redgifs.com/"]').one('mouseenter', function () {
if (options.allowHeadersRewrite) {
chrome.runtime.sendMessage({
action: "storeHeaderSettings",
plugin: 'custom',
settings:
[{
"skipInitiator":"redgifs",
"type": "request",
"urls": ["redgifs.com"],
"headers": [{ "name": "referer", "typeOfUpdate": "remove" }]
}]
});
}

$('a[href*="redgifs.com/"]').one('mouseenter', function() {
const link = $(this);
const gfyId = this.href.replace(/.*redgifs.com\/(..\/)?(\w+\/)?(\w+)(?:\.\w+)?/, '$3');

Expand Down Expand Up @@ -65,12 +79,16 @@ hoverZoomPlugins.push({
let videoUrlMobile = src;
let videoUrlBestQuality = videoUrlMobile.replace('-mobile', '');
let videoUrl = videoUrlMobile + '.video';
if (link.data().hoverZoomSrc == undefined) { link.data().hoverZoomSrc = [] }
if (link.data().hoverZoomSrc == undefined) {
link.data().hoverZoomSrc = []
}
if (link.data().hoverZoomSrc.indexOf(videoUrl) == -1) {
link.data().hoverZoomSrc.unshift(videoUrl);
}
videoUrl = videoUrlBestQuality + '.video';
if (link.data().hoverZoomSrc == undefined) { link.data().hoverZoomSrc = [] }
if (link.data().hoverZoomSrc == undefined) {
link.data().hoverZoomSrc = []
}
if (link.data().hoverZoomSrc.indexOf(videoUrl) == -1) {
link.data().hoverZoomSrc.unshift(videoUrl);
}
Expand Down

0 comments on commit 8998271

Please sign in to comment.