您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Helps Volafile users avoid certain problematic servers when uploading files, and allows raising the parallel-upload limit, up to 10.
当前为
- // ==UserScript==
- // @name Volafile Upload-Helper
- // @author Arnold François Lecherche and a Vola anon named Adonis
- // @namespace greasyfork.org
- // @icon https://volafile.org/favicon.ico
- // @version 1.00
- // @description Helps Volafile users avoid certain problematic servers when uploading files, and allows raising the parallel-upload limit, up to 10.
- // @include http://volafile.org/*
- // @include http://*.volafile.org/*
- // @include https://volafile.org/*
- // @include https://*.volafile.org/*
- // @grant none
- // @run-at document-end
- // @copyright 2021 Arnold François Lecherche
- // ==/UserScript==
- (function (w, d, M) {
- 'use strict';
- var a = false, nbRegEx = /^(?:(?:dl\d+|banger),)*(?:dl\d+|banger)|none$|^$/, commasRegExp = /,+$/,
- commaRegExp = /,/g, extRegExp = /\..+/, c, ulmenu, ub, r, up, k;
- function getCurrentProgressClass(t) {
- var server, blocklist, filespan, sinfo, x;
- if (this.upload.currentAttempt && this.upload.currentAttempt.info && this.upload.file.size > 1e7) {
- server = this.upload.currentAttempt.info.server;
- blocklist = new RegExp((c.ulblock || 'none').replace(commasRegExp, '').replace(commaRegExp, '\\\.|') + '\\\.');
- if (blocklist.test(server.replace(extRegExp, '.'))) {
- //r.extensions.chat.showMessage('Debug', 'skipping blacklisted server: ' + server, {'dontsave': true, 'staff': true});
- this.upload.tries -= 0.9;
- this.upload.currentAttempt.abort();
- } else {
- filespan = this.file.dom.nameElement;
- sinfo = filespan.querySelector('.sinfo') || filespan.appendChild(x = d.createElement('i'), (x.className = 'sinfo', x.style.color = 'rgba(255,255,255,0.53)'));
- sinfo.innerHTML = ' • ' + this.upload.currentAttempt.info.server;
- }
- }
- return 'progress_' + M.round(100 * this.lastProgress);
- }
- function remove() {
- if ('undefined' === typeof e) return;
- e.removeTimeout = null;
- e.forceRemove();
- }
- function setRemoveTimeout(t) {
- if (this.error) {
- this.file.dom.nameElement.innerHTML += ' • [<b>UPLOAD FAILED</b>]';
- //r.extensions.chat.showMessage('Upload Failed', this.file.name, {'dontsave': true, 'staff': true});
- return;
- }
- if (this.removeTimeout) w.clearTimeout(this.removeTimeout);
- this.removeTimeout = w.setTimeout(remove, t);
- }
- function isUploading() {
- var uppy = [up.uploadQueue.uploadQueue, up.runningUploads], i = uppy.length, j;
- while (i--) {
- j = uppy[i].length;
- while (j--) {
- uppy[i][j].getCurrentProgressClass = getCurrentProgressClass;
- uppy[i][j].setRemoveTimeout = setRemoveTimeout;
- }
- }
- return this.runningUploads.length > 0 || this.uploadQueue.length() > 0;
- }
- function set_mcu() {
- var mcu = M.floor(prompt('config.max_concurrent_uploads', c.max_concurrent_uploads));
- if (mcu != mcu || mcu < 1 || mcu > 10) return;
- this.innerText = '⮅ ' + (c.max_concurrent_uploads = mcu);
- }
- function set_block() {
- var block = prompt('Enter a comma-separated list of server prefixes to block, e.g. "dl8" or "dl7,dl8" (without quotes).', c.ulblock);
- if (block === null || block === false || !nbRegEx.test(block)) return;
- this.innerText = '🚫 ' + (c.ulblock = block);
- }
- function init() {
- if (a) return k && w.clearInterval(k);
- else k = k || w.setInterval(init, 1000);
- c = w.config;
- if (!c) return;
- ulmenu = w.ulmenu || d.createElement('div');
- ub = d.getElementById('upload_container');
- r = w.RoomInstance;
- if (!r) return;
- up = r.extensions.upload;
- up.isUploading = isUploading;
- ulmenu.id = 'ulmenu';
- ulmenu.setAttribute('style', 'display:inline-block;font-size:0.9em');
- ulmenu.innerHTML = '<a class="button" id="ul_mcu" title="set max concurrent uploads">⮅</a> ' +
- '<a class="button" id="ul_block" title="set upload blacklist">🚫</a> ';
- ub.insertBefore(ulmenu, ub.firstChild);
- d.getElementById('ul_mcu').addEventListener('click', set_mcu, false);
- d.getElementById('ul_block').addEventListener('click', set_block, false);
- a = true;
- if (k) w.clearInterval(k);
- }
- init();
- d.addEventListener('DOMContentLoaded', init, false);
- w.addEventListener('load', init, false);
- })(window, document, Math);