// ==UserScript==
// @name PT批量送魔力
// @namespace http://tampermonkey.net/
// @version 0.1.2
// @description PT站点批量送魔力脚本
// @author XGCM
// @match https://hdsky.me/mybonus.php
// @match https://pterclub.com/mybonus.php
// @match https://u2.dmhy.org/ucoin.php
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant GM_addElement
// @grant GM.xmlHttpRequest
// ==/UserScript==
var config = {
'https://hdsky.me': {
username: '#outer > table:nth-child(2) > tbody > tr:nth-child(11) > td:nth-child(3) > table > tbody > tr:nth-child(1) > td:nth-child(1) > input[type=text]',
amount: '#giftcustom',
message: '#outer > table:nth-child(2) > tbody > tr:nth-child(11) > td:nth-child(3) > table > tbody > tr:nth-child(2) > td > input[type=text]',
buttonRow: '#outer > table:nth-child(2) > tbody > tr:nth-child(11) > td:nth-child(5)',
messageRow: '#outer > table:nth-child(2) > tbody > tr:nth-child(11) > td:nth-child(3)',
option: 10,
interval: 0,
step: 10000
},
'https://pterclub.com': {
username: '#outer > table:nth-child(4) > tbody > tr:nth-child(16) > td:nth-child(3) > div > input[type=text]:nth-child(2)',
amount: '#giftcustom',
message: '#outer > table:nth-child(4) > tbody > tr:nth-child(16) > td:nth-child(3) > div > input[type=text]:nth-child(7)',
buttonRow: '#outer > table:nth-child(4) > tbody > tr:nth-child(16) > td:nth-child(5)',
messageRow: '#outer > table:nth-child(4) > tbody > tr:nth-child(16) > td:nth-child(3)',
option: 13,
interval: 0,
step: 10000
},
'https://u2.dmhy.org': {
url: 'https://u2.dmhy.org/mpshop.php',
username: '#outer > table > tbody > tr > td > table:nth-child(8) > tbody > tr > td > form > table > tbody > tr:nth-child(1) > td:nth-child(2) > input[type=text]',
amount: '#outer > table > tbody > tr > td > table:nth-child(8) > tbody > tr > td > form > table > tbody > tr:nth-child(2) > td:nth-child(2) > input[type=text]',
message: '#outer > table > tbody > tr > td > table:nth-child(8) > tbody > tr > td > form > table > tbody > tr:nth-child(3) > td:nth-child(2) > input[type=text]',
buttonRow: '#outer > table > tbody > tr > td > table:nth-child(8) > tbody > tr > td',
messageRow: '#outer > table > tbody > tr > td > table:nth-child(8) > tbody > tr > td',
option: 13,
interval: 305000,
step: 50000,
table: function() {return document.querySelector('#outer > table > tbody > tr > td > table:nth-child(4) > tbody > tr > td > table')},
}
}
var ERROR = '';
function getTable() {
var tableFunc = config[window.location.origin].table;
if (tableFunc === undefined)
return getNexusPHPTable();
return tableFunc();
}
function getNexusPHPTable() {
return document.getElementById('outer').getElementsByTagName('table')[0]
}
function bulkSend(username, amount, message) {
var url = config[window.location.origin].url !== undefined ? config[window.location.origin].url : window.location.origin + '/mybonus.php?action=exchange';
var option = config[window.location.origin].option;
var interval = config[window.location.origin].interval;
var step = config[window.location.origin].step;
var ref = setInterval(function() {
if (amount > step) {
sendNexusPHP(url, username, step, message, option);
amount -= step;
} else {
clearInterval(ref);
}
}, interval);
if (amount > 0) sendNexusPHP(url, username, step, message, option);
}
function sendNexusPHP(url, username, amount, message, option) {
console.log(url, username, amount, message, option);
var data;
if (window.location.origin === 'https://u2.dmhy.org') {
data = 'recv=' + username + '&amount=' + amount + '&message=' + message + '&event=1003';
} else {
data = 'username=' + username + '&bonusgift=' + amount + '&message=' + message + '&option=' + option + '&submit=赠送';
}
GM.xmlHttpRequest({
method: 'POST',
url: url,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
data: data,
onload: response => {
console.log(response.response);
if (response.response.indexOf('错误') == -1) {
var success = GM_addElement(document.querySelector(config[window.location.origin].messageRow), 'span', {});
success.innerHTML = '你成功发送了' + amount + '魔力' + '<br>';
} else {
var responseHTML = document.createElement('html');
responseHTML.innerHTML = response.response;
ERROR = responseHTML.querySelector('td[id="outer"] > table > tbody > tr > td').textContent;
var error = GM_addElement(document.querySelector(config[window.location.origin].messageRow), 'span', {});
error.innerHTML = ERROR + '<br>';
}
},
})
}
(function() {
'use strict';
var bulkButton = GM_addElement(document.querySelector(config[window.location.origin].buttonRow), 'button', {
id: 'send_bulk',
name: '批量赠送'
});
bulkButton.innerHTML = '批量赠送';
document.querySelector('button[name="批量赠送"]').onclick = function() {
var username = document.querySelector(config[window.location.origin].username);
var amount = document.querySelector(config[window.location.origin].amount);
var message = document.querySelector(config[window.location.origin].message);
if (isNaN(parseInt(amount.value, 10))) {
alert('魔力值须为数字!');
return
} else if (username.value === '') {
alert('用户名不能为空!');
return
} else {
bulkSend(username.value, amount.value, message.value);
username.value = '';
amount.value = '';
message.value = '';
}
}
})();