This repository has been archived by the owner on Aug 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathbooru.mass.uploader.user.js
93 lines (80 loc) · 2.86 KB
/
booru.mass.uploader.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// ==UserScript==
// @name Booru Mass Uploader
// @description Add ability to bulk upload images to your booru
// @namespace https://github.com/Seedmanc/Booru-mass-uploader
// @version 1.4.6
// @author Seedmanc
// @include http*://*.booru.org/index.php*
// @include http://rule34.xxx/index.php*
// @include https://gelbooru.com/index.php*
// @include http://safebooru.org/index.php*
// @include https://moe.dev.myconan.net/*
// @include http://behoimi.org/*
// @include https://chan.sankakucomplex.com/*
// @include http*://*allthefallen.moe/*
// @include http*://danbooru.donmai.us/*
// @exclude *.png
// @exclude *.jp*g
// @exclude *.gif
// @exclude *.webm
// you can add any boorus of your choice by following the pattern
// @grant none
// @run-at document-end
// @noframes
// ==/UserScript==
if (window.top != window.self) {
throw 'no iframes';
}
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);
}
if (~document.location.href.indexOf('s=mass_upload')) {
var script = document.createElement('script');
document.body.innerHTML = '<img src="https://seedmanc.github.io/Booru-mass-uploader/spinner.gif"/>';
script.src = 'https://seedmanc.github.io/Booru-mass-uploader/js/index.html.js?v=1.4.6';
script.onload = function () {
var scripts = document.getElementsByTagName('script');
activateScripts(scripts, 0);
};
document.body.appendChild(script);
} else {
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 = document.querySelector('meta[name="csrf-token"]');
token = token && token.content;
if (token) {
localStorage.setItem('auth_token', token);
}
if (document.querySelector('[src*="moe-legacy"]') || document.querySelector('html.action-post') || document.querySelector('[href*="/post/upload"]')) {
localStorage.setItem('current', 'moebooru');
} else if (document.querySelector('[href*="/uploads/new"]') || ~document.documentElement.innerHTML.indexOf('Running Danbooru')) {
localStorage.setItem('current', 'danbooru');
}
a.style.fontWeight = 'bold';
a.appendChild(document.createTextNode('Mass Upload'));
a.href = document.location.protocol + '//' + document.location.hostname + '/index.php?page=post&s=mass_upload';
if (navbar) {
li.appendChild(a);
navbar.appendChild(li);
} else {
a.style.display='block';
a.style.margin='auto';
a.style.width='105px';
document.body.insertBefore(a, document.body.firstChild);
}
}