File tree Expand file tree Collapse file tree 1 file changed +24
-5
lines changed Expand file tree Collapse file tree 1 file changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -216,12 +216,31 @@ function processArticle (data) {
216
216
217
217
// needed for wikipedia.org
218
218
219
- var images = doc . querySelectorAll ( 'img' )
219
+ var images = Array . from ( doc . getElementsByTagName ( 'img' ) )
220
220
221
- for ( var i = 0 ; i < images . length ; i ++ ) {
222
- if ( images [ i ] . src && images [ i ] . srcset ) {
223
- images [ i ] . srcset = ''
224
- }
221
+ if ( articleLocation . hostname . includes ( 'wikipedia.org' ) ) {
222
+ images . forEach ( function ( image ) {
223
+ if ( image . src && image . srcset ) {
224
+ image . srcset = ''
225
+ }
226
+ } )
227
+ }
228
+
229
+ if ( articleLocation . hostname === 'medium.com' ) {
230
+ // medium.com - show high-resolution images
231
+ var mediumImageRegex = / (?< = h t t p s ? : \/ \/ m i r o .m e d i u m .c o m \/ m a x \/ ) ( [ 0 - 9 ] + ) (? = \/ ) /
232
+ images . forEach ( function ( image ) {
233
+ if ( image . src ) {
234
+ // for gifs
235
+ image . src = image . src . replace ( '/freeze/' , '/' )
236
+ if ( mediumImageRegex . test ( image . src ) ) {
237
+ image . src = image . src . replace ( mediumImageRegex , '2000' )
238
+ }
239
+ } else {
240
+ // empty images (for lazy loading) mess up paragraph spacing
241
+ image . remove ( )
242
+ }
243
+ } )
225
244
}
226
245
227
246
extractAndShowNavigation ( doc )
You can’t perform that action at this time.
0 commit comments