diff --git a/booru.mass.uploader.user.js b/booru.mass.uploader.user.js index 66457bd..4e3587b 100644 --- a/booru.mass.uploader.user.js +++ b/booru.mass.uploader.user.js @@ -2,7 +2,7 @@ // @name Booru Mass Uploader // @description Add ability to bulk upload images to your booru // @namespace https://github.com/Seedmanc/Booru-mass-uploader -// @version 1.3.2 +// @version 1.3.3 // @author Seedmanc // @include http://*.booru.org/index.php* // @include http://rule34.xxx/index.php* @@ -13,82 +13,64 @@ // @include https://chan.sankakucomplex.com/* // @include http://atfbooru.ninja/* // @include http://danbooru.donmai.us/* +// @include http://eikonos.org/* // you can add any boorus of your choice by following the pattern // @grant none // @run-at document-end // @noframes - -// @require https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js // ==/UserScript== if (window.top != window.self) { throw 'no iframes'; } -var corses = ['www.whateverorigin.org/get?url=', 'crossorigin.me/']; - -function onSuccess(response) { - var scripts; - - document.getElementsByTagName('body')[0].innerHTML = response; - scripts = document.getElementsByTagName('script'); - - for (var i = 0; i < scripts.length; i++) { - var node = scripts[i], parent = node.parentElement, d = document.createElement('script'); - - d.async = node.async; - d.src = node.src; - parent.insertBefore(d, node); - parent.removeChild(node); - } +function activateScripts(scripts, i) { + var node = scripts[i], + parent = node.parentElement, + d = document.createElement('script'); + + d.async = node.async; + d.src = node.src; + d.onload = function () { + if (i < scripts.length - 1) { + activateScripts(scripts, i + 1); + } + }; + parent.insertBefore(d, node); + parent.removeChild(node); } -function tryCors(idx) { - - idx = idx || 0; - - if (!corses[idx]) { - document.write('Ran out of CORS engines, try later'); - return; - } +if (~document.location.href.indexOf('s=mass_upload')) { + var script = document.createElement('script'); - (idx ? $.get : $.getJSON)(location.protocol + '//' + corses[idx] + 'http://seedmanc.github.io/Booru-mass-uploader/index.html' + (idx ? '' : '&callback=?')) - .done(function (response) { - onSuccess(response.contents || response); - }) - .fail(function (response) { - if (response.status == 200 && response.readyState == 4) { - onSuccess(response.responseText); - } else { - console.log(response); - tryCors(idx + 1); - } - }); -} + document.body.innerHTML = ''; + script.src = 'https://seedmanc.github.io/Booru-mass-uploader/js/index.html.js'; + script.onload = function () { + var scripts = document.getElementsByTagName('script'); -if (~document.location.href.indexOf('s=mass_upload')) { - document.write(''); - tryCors(); + activateScripts(scripts, 0); + }; + document.body.appendChild(script); } else { - var navbar = $('#navbar')[0] || - $('.flat-list2')[0] || - $('#main-menu > ul')[0] || - $('nav > menu')[0]; + var navbar = document.getElementById('navbar') || + document.getElementsByClassName('flat-list2')[0] || + document.querySelector('#main-menu > ul') || + document.querySelector('nav > menu'); var li = document.createElement("li"); var a = document.createElement("a"); - var token = $('meta[name="csrf-token"]')[0]; + var token = document.querySelector('meta[name="csrf-token"]'); token = token && token.content; if (token) { localStorage.setItem('auth_token', token); } - if ($('[src*="moe-legacy"]').length || $('html.action-post').length || $('[href*="/post/upload"]').length) { + if (document.querySelector('[src*="moe-legacy"]') || document.querySelector('html.action-post') || document.querySelector('[href*="/post/upload"]')) { localStorage.setItem('current', 'moebooru'); - } else if ($('[href*="/uploads/new"]').length || ~document.documentElement.innerHTML.indexOf('Running Danbooru')) { + } else if (document.querySelector('[href*="/uploads/new"]') || ~document.documentElement.innerHTML.indexOf('Running Danbooru')) { localStorage.setItem('current', 'danbooru'); } @@ -101,4 +83,4 @@ if (~document.location.href.indexOf('s=mass_upload')) { a.href = document.location.protocol + '//' + document.location.hostname + '/index.php?page=post&s=mass_upload'; li.appendChild(a); navbar.appendChild(li); -} +} \ No newline at end of file diff --git a/index.html b/index.html index 49f5b48..b8d6421 100644 --- a/index.html +++ b/index.html @@ -17,7 +17,7 @@ } p.intro, q { - font-style: italic; + font-weight: bold; } fieldset { @@ -131,20 +131,9 @@
-This script allows you to mass-upload images to imageboard sites running *booru software. - Select a number of files and they're sent to the website along with the metadata you include such as - the tags retrived from the filenames.
+Support for the old version will be dropped by next release. The new version finally fixes the white screen/HTTPS unavailability/FF loading issues for good.