|  | // ==UserScript== | 
        
          |  | // @name         Embiggener | 
        
          |  | // @namespace    http://tampermonkey.net/ | 
        
          |  | // @version      0.1 | 
        
          |  | // @description  Finds the biggest possible version of any image | 
        
          |  | // @author       Hayden Schiff (oxguy3) | 
        
          |  | // @match        *://*/* | 
        
          |  | // @grant        unsafeWindow | 
        
          |  | // ==/UserScript== | 
        
          |  |  | 
        
          |  | function runParsers() { | 
        
          |  |  | 
        
          |  | var parsers = [ | 
        
          |  | parseYouTube, | 
        
          |  | parseFlickr, | 
        
          |  | parseBandcamp, | 
        
          |  | parseWikimedia, | 
        
          |  | parseTwitter | 
        
          |  | ]; | 
        
          |  |  | 
        
          |  | var result = null; | 
        
          |  |  | 
        
          |  | parsers.forEach(function(parser) { | 
        
          |  | if (result !== null) return; | 
        
          |  | console.log("Testing "+parser.name.substring(5)+"..."); | 
        
          |  | result = parser(window.location); | 
        
          |  | }); | 
        
          |  |  | 
        
          |  | if (result !== null) { | 
        
          |  | window.location = result; | 
        
          |  | } else { | 
        
          |  | alert("Failed to embiggen! :("); | 
        
          |  | } | 
        
          |  | } | 
        
          |  |  | 
        
          |  | function parseYouTube(location) { | 
        
          |  | if (location.hostname == "i.ytimg.com") { | 
        
          |  | var re = /^\/vi\/([^"&?/ ]{11})\/\w+.jpg$/ig; | 
        
          |  | var result = re.exec(location.pathname); | 
        
          |  | if (result !== null) { | 
        
          |  | var videoId = result[1]; | 
        
          |  | return "https://i.ytimg.com/vi/"+videoId+"/maxresdefault.jpg"; | 
        
          |  | } | 
        
          |  | } | 
        
          |  | return null; | 
        
          |  | } | 
        
          |  |  | 
        
          |  | function parseFlickr(location) { | 
        
          |  | if (/farm\d\.staticflickr\.com/gi.test(location.hostname)) { | 
        
          |  | var re = /^\/\d{4}\/(\d{1,11})_[0-9a-f]{10}_\w(?:_d)?.jpg$/ig; | 
        
          |  | var result = re.exec(location.pathname); | 
        
          |  | if (result !== null) { | 
        
          |  | var photoId = result[1]; | 
        
          |  | return "https://flickr.com/photo.gne?id="+photoId; | 
        
          |  | } | 
        
          |  | } | 
        
          |  | return null; | 
        
          |  | } | 
        
          |  |  | 
        
          |  | function parseBandcamp(location) { | 
        
          |  | if (/f\d\.bcbits\.com/gi.test(location.hostname)) { | 
        
          |  | var re = /^\/img\/(a?\d{10})_\d+.jpg$/ig; | 
        
          |  | var result = re.exec(location.pathname); | 
        
          |  | if (result !== null) { | 
        
          |  | var imgId = result[1]; | 
        
          |  | return "https://f1.bcbits.com/img/"+imgId+"_0.jpg"; | 
        
          |  | } | 
        
          |  | } | 
        
          |  | return null; | 
        
          |  | } | 
        
          |  |  | 
        
          |  |  | 
        
          |  | function parseWikimedia(location) { | 
        
          |  | if (location.hostname == "upload.wikimedia.org") { | 
        
          |  | var re = /^\/(\w+)\/(\w+)(?:\/thumb)?\/[0-9a-f]\/[0-9a-f]{2}\/([^#<>\[\]\|\{\}\/]+)(?:\/(?:page\d+-)?\d+px-[^#<>\[\]\|\{\}\/]+)?$/ig; | 
        
          |  | var result = re.exec(location.pathname); | 
        
          |  | if (result !== null) { | 
        
          |  | var website = result[1]; | 
        
          |  | var language = result[2]; | 
        
          |  | var filename = result[3]; | 
        
          |  |  | 
        
          |  | // special case for .wikimedia.org domains | 
        
          |  | var specialLanguages = [ "commons", "species", "meta" ]; | 
        
          |  | if (website == "wikipedia" && specialLanguages.indexOf(language) != -1) { | 
        
          |  | website = "wikimedia"; | 
        
          |  | } | 
        
          |  |  | 
        
          |  | return "https://"+language+"."+website+".org/wiki/File:"+filename; | 
        
          |  | } | 
        
          |  | } | 
        
          |  | return null; | 
        
          |  | } | 
        
          |  |  | 
        
          |  | function parseTwitter(location) { | 
        
          |  | if (location.hostname == "pbs.twimg.com") { | 
        
          |  | var re = /^\/media\/([\w\d_]+)\.(\w+)(?:\:\w+)?$/ig; | 
        
          |  | var result = re.exec(location.pathname); | 
        
          |  | if (result !== null) { | 
        
          |  | var imageId = result[1]; | 
        
          |  | var fileExt = result[2]; | 
        
          |  | return "https://pbs.twimg.com/media/"+imageId+"."+fileExt+":large"; | 
        
          |  | } | 
        
          |  | } | 
        
          |  | return null; | 
        
          |  | } | 
        
          |  |  | 
        
          |  | (function() { | 
        
          |  | 'use strict'; | 
        
          |  |  | 
        
          |  | unsafeWindow.runEmbiggener = runParsers; | 
        
          |  | })(); |