﻿// ==UserScript==
// @name		Booru Mass Uploader
// @description	 Add ability to bulk upload images to your booru
// @version	1.0
// @author		Seedmanc
// @include	http://*.booru.org/index.php?page=*&s=mass_upload

function loadAndExecute(url, callback){											
	var scriptNode = document.createElement ("script");	
	scriptNode.addEventListener("load", callback);
	scriptNode.onerror = function(){ 
		throw new Error("Can't load "+url);
	};
	scriptNode.src = url;
	document.head.appendChild(scriptNode);
};

(function(){
	if (window.top != window.self)  											
		return;
	//loadAndExecute("https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js", main);
	
	var xhr= new XMLHttpRequest();
	xhr.open('GET', 'http://crossorigin.me/http://seedmanc.github.io/Booru-mass-uploader/index.html', true);
	xhr.onreadystatechange= function() {
		if (this.readyState != 4) return;
		if (this.status != 200) return; // or whatever error handling you want
		document.getElementsByTagName('body')[0].innerHTML = this.responseText;
		var s = document.getElementsByTagName('script');
for (var i = 0; i < s.length ; i++) {
  var node=s[i], parent=node.parentElement, d = document.createElement('script');
  d.async=node.async;
  d.src=node.src;
  parent.insertBefore(d,node);
  parent.removeChild(node);
}
	};
	xhr.send();
	
})();

function main(){
	
}
@@ -179,38 +179,28 @@
 org/
-index.php?page=*&s=mass_upload
+*%0A// ==/UserScript==
 %0A%0Afu
@@ -567,103 +567,68 @@
 n;%0A%09
-//loadAndExecute(%22https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js%22, main);%0A
+%0A%09if (~document.location.href.indexOf('s=mass_upload')) %7B
 %09%0A
+%09
 %09var
@@ -655,16 +655,17 @@
 uest();%0A
+%09
 %09xhr.ope
@@ -762,16 +762,17 @@
  true);%0A
+%09
 %09xhr.onr
@@ -801,16 +801,17 @@
 ion() %7B%0A
+%09
 %09%09if (th
@@ -840,16 +840,17 @@
 turn;%0A%09%09
+%09
 if (this
@@ -912,16 +912,17 @@
 ou want%0A
+%09
 %09%09docume
@@ -989,16 +989,17 @@
 Text;%0A%09%09
+%09
 var s = 
@@ -1039,16 +1039,19 @@
 ript');%0A
+%09%09%09
 for (var
@@ -1080,18 +1080,20 @@
  i++) %7B%0A
-  
+%09%09%09%09
 var node
@@ -1164,18 +1164,20 @@
 ript');%0A
-  
+%09%09%09%09
 d.async=
@@ -1188,18 +1188,20 @@
 .async;%0A
-  
+%09%09%09%09
 d.src=no
@@ -1208,18 +1208,20 @@
 de.src;%0A
-  
+%09%09%09%09
 parent.i
@@ -1241,18 +1241,20 @@
 ,node);%0A
-  
+%09%09%09%09
 parent.r
@@ -1275,14 +1275,19 @@
 e);%0A
+%09%09%09
 %7D%0A
+%09
 %09%7D;%0A
+%09
 %09xhr
@@ -1300,32 +1300,850 @@
 );%0A%09
-%0A%7D)();%0A%0Afunction main()%7B%0A%09%0A%7D
+%7D else if (~document.location.href.indexOf('?page='))%0A%09%09//document.addEventListener('DOMContentLoaded', function()%0A%09%09%7B%0A%09%09%09var navbar = document.getElementById('navbar');%0A%09%09%09var notice = document.getElementById('notice').previous() ;%0A%09%09%09notice.parentNode.removeChild(notice);%0A%09%09%09var longnotice = document.getElementById('long-notice');%0A%09%09%09longnotice.parentNode.removeChild(longnotice);%0A%09%09%09var ad = document.querySelectorAll('center div%5Bid*=%22adbox%22%5D')%5B0%5D.parentNode;%0A%09%09%09ad.parentNode.removeChild(ad);%0A%09%09%09%0A%09%09%09var li = document.createElement(%22li%22);%0A%09%09%09var a  = document.createElement(%22a%22);%0A%09%09%09a.style= %22font-weight:bold;%22;%0A%09%09%09a.appendChild(document.createTextNode('Mass Upload'));%0A%09%09%09a.href = document.location.href.split('.')%5B0%5D+'.booru.org/index.php?page=post&s=mass_upload';%0A%09%09%09li.appendChild(a);%0A%09%09%09navbar.appendChild(li);%0A%09%09%7D//, false); %09%0A%7D)(); 

integrate link to uploader