geekhack

Site Announcements and Feedback => Announcements/Feedback/Suggestions => Topic started by: homerowco on Tue, 26 June 2018, 10:53:59

Title: GH Imgur Fixer
Post by: homerowco on Tue, 26 June 2018, 10:53:59
Extensions:

Chrome (unlisted):
https://chrome.google.com/webstore/detail/gh-imgur-fix/ckkmbgkaejlabflnopigihodicamibjn

Firefox (all platforms - experimental tag):
https://addons.mozilla.org/en-US/firefox/addon/gh-imgur-fix/

Safari (hosted on Github - unpublished - proxy method):
https://github.com/homerowco/GHimgurFix/raw/master/ext/safari/dist/craycopy.safariextz



Source:

Source Repo:
https://github.com/homerowco/GHimgurFix

Stack:
Simple PHP proxy script that runs on a AWS Elastic Beanstalk which is proxied by Cloudflare to cache everything going through assuring a 100% CDN cache rate.
The Chrome extension is a content match injection on *geekhack.org* that replaces all imgur images and links (zoom) with the same source but adds the proxy domain in front of it.
It's currently running on craycopy.com (random old domain) and since it's all cached via Cloudflare it's not really costing me much besides the $5/mo for the nano EB instance.


Update: The extensions are now serverless and modify the request header on demand! Much better, much faster.

Want to change something? Pull request! :)



Example:

Broken:
More
Code: [Select]
https://i.imgur.com/Tiur5Eg.jpg(https://i.imgur.com/Tiur5Eg.jpg)

Fixed (old proxy):
More
Code: [Select]
https://craycopy.com/i/https://i.imgur.com/Tiur5Eg.jpg(https://craycopy.com/i/https://i.imgur.com/Tiur5Eg.jpg)




JS Alternatives:

Update: I tried to modify the request headers via jquery/native and it's not possible. All modern browsers refuse the editing of request headers. The proxy url rewrite method is still the only working one for directly inside the website implementation without installing the extensions.

jQuery (avail. on GH):
Code: [Select]
$(function(){
var f='://i.imgur.com/',r='https://craycopy.com/';
$.each([['img.bbc_img[','src'],['a.highslide[','href']],function(k,v){
$(v[0]+v[1]+'*="'+f+'"]').each(function(){var t=$(this),s=t.attr(v[1]);-1===s.indexOf(r)&&t.attr(v[1],r+'i/'+s)});
});
});

Vanilla:
Code: [Select]
(function(){
var f='://i.imgur.com/',r='https://craycopy.com/',a=[['img.bbc_img[','src'],['a.highslide[','href']],g,h,x;
for(g in a){for(h of document.querySelectorAll(a[g][0]+a[g][1]+'*="'+f+'"]'))(x=h[a[g][1]])&&-1===x.indexOf(r)&&(h[a[g][1]]=r+'i/'+x)}
})();
Title: Re: GH Imgur Fixer
Post by: homerowco on Tue, 26 June 2018, 18:26:43
UPDATE:

General:
 - Safari support was added via proxy bypass because Safari does not support header rewrites
 - added zoom in link support to Safari extension


v0.1.1:
 - slight modification to support Mozilla Firefox on all Platforms

v0.1.0:
 - no more server needed!
(thanks to webRequest modification of the headers and user Antarctidad for pointing me in the right direct!)

v0.0.6:
 - cleanup and manual minification of code

v0.0.5:
 - merged link and img tag check into one loop

v0.0.3/4:
 - added stricter element selector

v0.0.2:
 - fixes zoom in view to work as well!
Title: Re: GH Imgur Fixer
Post by: voodoo6k on Wed, 27 June 2018, 07:56:22
Thanks.

Is GH aware of the problem / working on a fix?
Title: Re: GH Imgur Fixer
Post by: dgneo on Wed, 27 June 2018, 08:31:30
Thanks.

Is GH aware of the problem / working on a fix?

https://geekhack.org/index.php?topic=96312.msg2629292#msg2629292
Title: Re: GH Imgur Fixer
Post by: homerowco on Wed, 27 June 2018, 10:00:42
Thanks.

Is GH aware of the problem / working on a fix?

Can't be fixed directly - imgur basically blocked geekhack it seems.
My fix rewrites the urls and then proxies images creating a technical fix for it.

The extension works on chrome until someone makes a version for safari/firefox (does chrome work on firefox?) or tells me how to do it haha.

Other than that the GH admins could put the above provided JS directly into the page to also "fix" it :)
Title: Re: GH Imgur Fixer
Post by: janglad on Thu, 28 June 2018, 07:58:19
Thanks for this!!  :thumb:
Title: Re: GH Imgur Fixer
Post by: Coreda on Thu, 28 June 2018, 08:05:14
Can't be fixed directly - imgur basically blocked geekhack it seems.

I think what the gh admin will have to do if they want to actually resolve the blacklisting is enforce a rule to stop using Imgur for images in the classifieds and for signatures, as that seems to be the cause.

Apart from that appreciate someone has made a short term fix :thumb:
Title: Re: GH Imgur Fixer
Post by: homerowco on Thu, 28 June 2018, 08:26:49
Added Firefox extension for all platforms (seems like this will even work on Android) and replaced the proxy rewrite code with native web request modifications!

It just became much faster and better and no need for additional requests, plus its now also on a lot more browsers :)

Check original post above for details!
Title: Re: GH Imgur Fixer
Post by: ojrask on Thu, 28 June 2018, 13:48:56
Ooh, I thought my adblocking settings were fugged and it prevented the images from loading. Really sucky as there are years of images in here which are now broken.
Title: Re: GH Imgur Fixer
Post by: homerowco on Thu, 28 June 2018, 15:54:28
I got Safari to work - the old method via proxy CDN because Safari does not allow devs to adjust the outgoing request headers.
Better than nothing ;)
Title: Re: GH Imgur Fixer
Post by: Puddsy on Thu, 28 June 2018, 22:02:57
I've forwarded this to someone who works for Imgur (not support). Stay tuned.
Title: Re: GH Imgur Fixer
Post by: SpAmRaY on Thu, 28 June 2018, 22:09:48
I've forwarded this to someone who works for Imgur (not support). Stay tuned.
Nice

Sent from my SM-G930V using Tapatalk

Title: Re: GH Imgur Fixer
Post by: Puddsy on Thu, 28 June 2018, 22:13:12
I've forwarded this to someone who works for Imgur (not support). Stay tuned.
Nice

Sent from my SM-G930V using Tapatalk

damn right
Title: Re: GH Imgur Fixer
Post by: homerowco on Fri, 29 June 2018, 05:08:53
I've forwarded this to someone who works for Imgur (not support). Stay tuned.

make sure not to mention that extension lol...

just ask them how to get geekhack.org unblocked.
Title: Re: GH Imgur Fixer
Post by: dgneo on Fri, 29 June 2018, 05:31:02
(not support)

clutch
Title: Re: GH Imgur Fixer
Post by: Puddsy on Fri, 29 June 2018, 17:36:35
Issue has been fixed.

Explanation I was given was, "Internal issue that I am not allowed to explain."

But pictures work again.

"If it happens again just email support@imgur.com and just explain that the site is being hotlinked blocked but you don’t believe the site is violating any ToS"
Title: Re: GH Imgur Fixer
Post by: romevi on Fri, 29 June 2018, 17:59:35
Just when I was debating on posting a "Show your white pixels!" thread...
Title: Re: GH Imgur Fixer
Post by: SeedyOne on Fri, 29 June 2018, 20:59:20
Issue has been fixed.

Explanation I was given was, "Internal issue that I am not allowed to explain."

But pictures work again.

"If it happens again just email support@imgur.com and just explain that the site is being hotlinked blocked but you don’t believe the site is violating any ToS"

Thanks!  :thumb:
Title: Re: GH Imgur Fixer
Post by: Puddsy on Fri, 29 June 2018, 21:34:01
If it's still happening for you, clear your cache. If it's still happening in ~48 hours I'll send an email to support.