From 9d8bcbce37dd348d706aa104e9c4592a873d5bd0 Mon Sep 17 00:00:00 2001 From: jgen Date: Sun, 24 Nov 2013 14:54:10 -0500 Subject: [PATCH] Fixed bookmarklet.js to allow uploading from Gelbooru. (was broken before) --- ext/upload/bookmarklet.js | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/ext/upload/bookmarklet.js b/ext/upload/bookmarklet.js index 519adcfe..e902d135 100644 --- a/ext/upload/bookmarklet.js +++ b/ext/upload/bookmarklet.js @@ -142,14 +142,23 @@ else if(document.getElementById("tags") !== null) { // Can't seem to grab source due to url containing a & // var source="http://" + document.location.hostname + document.location.href.match("\/index\.php?page=post&s=view\\&id=.*"); - var gmi = document.getElementById("image").src.match(".*img[0-9]+\.gelbooru\.com\/\/images\/[0-9]+\/[a-z0-9]+\.[a-z0-9]+")[0]; - - // Since Gelbooru does not allow flash, no need to search for flash tag. - // Gelbooru doesn't show file size in statistics either... - if(supext.search(gmi.match("http\:\/\/.*\\.([a-z0-9]+)")[1]) !== -1){ - location.href = ste+gmi+"&tags="+tag+"&rating="+rating;//+"&source="+source; + + // Updated Nov. 24, 2013 by jgen. + var gmi; + try { + gmi = document.getElementById("image").src.match(".*img[0-9]*\.gelbooru\.com[\/]+images[\/]+[0-9]+[\/]+[a-z0-9]+\.[a-z0-9]+")[0]; + + // Since Gelbooru does not allow flash, no need to search for flash tag. + // Gelbooru doesn't show file size in statistics either... + if(supext.search(gmi.match("http\:\/\/.*\\.([a-z0-9]+)")[1]) !== -1){ + location.href = ste+gmi+"&tags="+tag+"&rating="+rating;//+"&source="+source; + } + else{ + alert(notsup); + } } - else{ - alert(notsup); + catch (err) + { + alert("Unable to locate the image on the page!\n(Gelbooru may have changed the structure of their page, please file a bug.)"); } }