Booru bookmarklet now works with shimmie sites + is now loaded via .js script on the site.
This commit is contained in:
parent
7759700160
commit
fcb8307f58
42
ext/upload/bookmarklet.js
Normal file
42
ext/upload/bookmarklet.js
Normal file
@ -0,0 +1,42 @@
|
||||
/* Imageboard to Shimmie */
|
||||
// This should work with "most" sites running Danbooru/Gelbooru/Shimmie
|
||||
// Danbooru
|
||||
if(document.getElementById("post_tags") !== null){
|
||||
var tag=document.getElementById("post_tags").value;
|
||||
var rtg=document.documentElement.innerHTML.match("<li>Rating: (.*)<\/li>")[1];
|
||||
var srx="http://" + document.location.hostname + document.location.href.match("\/post\/show\/[0-9]+\/");
|
||||
if(tag.search(/\bflash\b/)==-1){
|
||||
location.href=ste+document.getElementById("highres").href+"&tags="+tag+"&rating="+rtg[1]+"&source="+srx;
|
||||
}else{
|
||||
location.href=ste+document.getElementsByName("movie")[0].value+"&tags="+tag+"&rating="+rtg[1]+"&source="+srx;
|
||||
}
|
||||
}
|
||||
/* Shimmie
|
||||
Shimmie doesn't seem to have any way to grab tags via id unless you have the ability to edit tags.
|
||||
Have to go the round about way of checking the title for tags.
|
||||
This crazy way of checking "should" work with older releases though (Seems to work with 2009~ ver) */
|
||||
else if(document.getElementsByTagName("title")[0].innerHTML.search("Image [0-9.-]+\: ")==0){
|
||||
var tag=document.getElementsByTagName("title")[0].innerHTML.match("Image [0-9.-]+\: (.*)")[1];
|
||||
//TODO: Make rating show in statistics.
|
||||
var srx="http://" + document.location.hostname + document.location.href.match("\/post\/view\/[0-9]+");
|
||||
/*TODO: Figure out regex for shortening file link.
|
||||
I.E http://blah.net/_images/1234abcd/everysingletag.png > http://blah.net/_images/1234abcd.png
|
||||
.match("WEBSITE.NET\/_images\/[A-Za-z0-9]+", "(\\.[a-z][a-z]+)")*/
|
||||
if(tag.search(/\bflash\b/)==-1){
|
||||
location.href=ste+document.getElementById("main_image").src+"&tags="+tag+"&source="+srx;
|
||||
}else{
|
||||
location.href=ste+document.location.hostname+document.getElementsByName("movie")[0].value+"&tags="+tag+"&source="+srx;
|
||||
}
|
||||
}/*
|
||||
// Gelbooru
|
||||
else if(document.getElementById("tags") !== null){
|
||||
//Gelbooru has an annoying anti-hotlinking thing which doesn't seem to like the bookmarklet...
|
||||
//So if someone can figure out how to bypass the hotlinking, please update the code :<
|
||||
var ste="http://localhost/shimmie_trunk/upload?url=";
|
||||
var tag=document.getElementById("tags").value;
|
||||
var rtg=document.documentElement.innerHTML.match("<li>Rating: (.*)<\/li>")[1];
|
||||
var srx="http://" + document.location.hostname + document.location.href.match("\/index\.php\\?page=post&s=view&id=.*"); //Gelbooru has really ugly urls..
|
||||
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.
|
||||
location.href=ste+gmi+"&tags="+tag+"&rating="+rtg[1]+"&source="+srx';
|
||||
}*/
|
@ -140,34 +140,15 @@ class UploadTheme extends Themelet {
|
||||
$html .= '<p><a href=\''.$js.'\'>Upload to '.$title.'</a> (Drag & drop onto your bookmarks toolbar, then click when looking at an image)';
|
||||
}
|
||||
{
|
||||
/* Danbooru > Shimmie Bookmarklet.
|
||||
This "should" work on any site running danbooru, unless for some odd reason they switched around the id's or aren't using post/list.
|
||||
Most likely this will stop working when Danbooru updates to v2, all depends if they switch the ids or not >_>.
|
||||
Clicking the link on a danbooru image page should give you something along the lines of:
|
||||
'http://www.website.com/shimmie/upload?url="http://sonohara.donmai.us/data/crazylongurl.jpg&tags="too many tags"&rating="s"&source="http://danbooru.donmai.us/post/show/012345/"'
|
||||
TODO: Possibly make the entire/most of the script into a .js file, and just make the bookmarklet load it on click (Something like that?)
|
||||
/* Imageboard > Shimmie Bookmarklet
|
||||
This is more or less, an upgraded version of the "Danbooru>Shimmie" bookmarklet.
|
||||
At the moment this works with Shimmie & Danbooru.
|
||||
It would also work with Gelbooru but unless someone can figure out how to bypass their hotlinking..meh.
|
||||
The bookmarklet is now also loaded via the .js file in this folder.
|
||||
*/
|
||||
$title = "Danbooru to " . $config->get_string('title');
|
||||
$html .= '<p><a href="javascript:'.
|
||||
/* This should stop the bookmarklet being insanely long...not that it's already huge or anything. */
|
||||
'var ste="'. $link . $delimiter .'url=";var tag=document.getElementById("post_tags").value;var rtg=document.documentElement.innerHTML.match("<li>Rating: (.*)<\/li>");var srx="http://" + document.location.hostname+document.location.href.match("\/post\/show\/.*\/");' .
|
||||
//The default confirm sucks, mainly due to being unable to change the text in the Ok/Cancel box (Yes/No would be better.)
|
||||
'if (confirm("OK = Use Current tags.\nCancel = Use new tags.")==true){' . //Just incase some people don't want the insane amount of tags danbooru has.
|
||||
//The flash check is kind of picky, although it should work on "most" images..there will be either some old or extremely new ones that lack the flash tag.
|
||||
'if(tag.search(/\bflash\b/)==-1){'.
|
||||
'location.href=ste+document.getElementById("highres").href+"&tags="+tag+"&rating="+rtg[1]+"&source="+srx;}'.
|
||||
'else{'.
|
||||
'location.href=ste+document.getElementsByName("movie")[0].value+"&tags="+tag+"&rating="+rtg[1]+"&source="+srx;}'.
|
||||
//The following is more or less the same as above, instead using the tags on danbooru, should load a prompt box instead.
|
||||
'}else{'.
|
||||
'var p=prompt("Enter Tags","");'.
|
||||
'if(tag.search(/\bflash\b/)==-1){'.
|
||||
'location.href=ste+document.getElementById("highres").href+"&tags="+p+"&rating="+rtg[1]+"&source="+srx;}' .
|
||||
'else{'.
|
||||
'location.href=ste+document.getElementsByName("movie")[0].value+"&tags="+p+"&rating="+rtg[1]+"&source="+srx;}'.
|
||||
'}">' .
|
||||
$title . '</a> (As above, Click on a Danbooru-run image page. (This also grabs the tags/rating/source!))';
|
||||
|
||||
$title = "Booru to " . $config->get_string('title');
|
||||
$html .= '<p><a href="javascript:var ste="'. $link . $delimiter .'url="; void(document.body.appendChild(document.createElement("script")).src="'.make_http(make_link("ext/upload/bookmarklet.js")).'")">'.
|
||||
$title . '</a> (Click when looking at an image page. Works on sites running Shimmie or Danbooru. (This also grabs the tags/rating/source!))';
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user