// ==UserScript==
// @name B站直播硬币兑换瓜子翻倍|Bilibili直播
// @name:zh-TW B站直播硬幣兌換瓜子翻倍|Bilibili直播
// @version 0.1
// @description 通过旧兑换接口,获得双倍银瓜子,每日上限还是10硬币
// @description:zh-TW 通過舊兌換介面,獲得雙倍銀瓜子,每日上限還是10硬幣
// @author QHS
// @match *://live.bilibili.com/exchange
// @require https://code.jquery.com/jquery-3.2.1.min.js
// @grant GM_addStyle
// @icon https://live.bilibili.com/favicon.ico
// @supportURL https://gf.qytechs.cn/scripts/37085/
// @supportURL https://steamcommunity.com/profiles/76561198132556503
// @namespace https://gf.qytechs.cn/users/155548
// ==/UserScript==
(function() {
var titleT = "双倍兑换成功",
titleF = "双倍兑换出错",
contentF = "可能此功能已关闭,可在<a target=_blank href='https://gf.qytechs.cn/scripts/37085/'>此处查看详情或提交反馈</a>",
titleN = "网络超时",
contentN = "请检查网络后再试";
GM_addStyle('.highlight-double{color: #7dff7b;}.moresilver{font-size: 14px; text-align: center; height: 30px; line-height: 30px; border: none; padding: 0 33px!important; margin-top: 50px; border-radius: 15px; color: #fff; background-color: #7dff7b!important; cursor: pointer;margin-left: 10px;}');
$("#coin-to-silver-btn").after('<input type="button" value="双倍兑换 (900瓜子/硬币)" class="moresilver">');
$("#coin-to-silver-btn").val('单倍兑换');
$(".input-desc").html('单倍兑换将获得(<font class="coin-available">查询中</font>): <span class="highlight"><em class="silver-num">0</em>银瓜子</span><br>双倍兑换将获得(每日最多使用10硬币): <span class="highlight-double"><em class="silver-num-double">0</em>银瓜子</span>');
$("p#coin-seed-desc").before('<p style=margin:0 class="desc">每日每个用户<span class="highlight-double">使用脚本</span>可以最多将10个硬币变成银瓜子,硬币兑换银瓜子比率为<span class="highlight-double">1硬币=900银瓜子</span>。</p>');
//$.get('//api.live.bilibili.com/pay/v1/Exchange/getStatus?platform=pc',{xhrFields: { withCredentials: true },crossDomain: true},function(data) {$('.coin-available').html('今日还可兑换'+data.coin_2_silver_left+'硬币');});
$('.form-box').on('click', '.moresilver',
function() {
if ($('#coin-num').val() < 1 || $('#coin-num').val() > 10) {
_popup('双倍兑换出错', '请输入正确的硬币数量');
return false;
}
$.ajax({
type: 'post',
url: '/exchange/coin2silver',
data: {
coin: $('#coin-num').val(),
},
timeout: 8000,
complete: function(XMLHttpRequest, status) {
if (status != 'timeout' && status != 'success') {
_popup(titleF, contentF);
}
if (status == 'timeout') {
_popup(titleN, contentN);
}
},
success: function(data) {
if (!data.hasOwnProperty("code")) {
_popup(titleF, contentF);
} else if (data.code == 0) {
_popup(titleT, '成功兑换<span class="highlight">' + data.data.silver + '</span>银瓜子,当前银瓜子数量:<font class="silver-ammount">查询中</font>');
$.ajax({
type: 'get',
url: '//api.live.bilibili.com/pay/v1/Exchange/getStatus?platform=pc',
crossDomain: true,
xhrFields: {
withCredentials: true
},
timeout: 8000,
complete: function(XMLHttpRequest, status) {},
success: function(data) {
$('.silver-ammount').html(data.data.silver);
}
});
} else {
_popup(titleF, data.msg);
}
}
});
});
$.ajax({
type: 'get',
url: '//api.live.bilibili.com/pay/v1/Exchange/getStatus?platform=pc',
crossDomain: true,
xhrFields: {
withCredentials: true
},
timeout: 8000,
complete: function(XMLHttpRequest, status) {},
success: function(data) {
$('.coin-available').html('今日还可兑换' + data.data.coin_2_silver_left + '硬币');
}
});
$('body').on('click', '.tip-close',
function() {
$('.center-tip-wrapper.radius').remove();
});
$('body').on('click', '#keep-here',
function() {
$('.center-tip-wrapper.radius').remove();
});
$('.form-box-wrap').on('input propertychange', '#coin-num',
function() {
$('.silver-num-double').html($('#coin-num').val() * 900);
});
function _popup(a, b) {
$('body').prepend('<div class="center-tip-wrapper radius" style="box-shadow: #806363 7px 4px 10px;width: 350px; display: block; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); -ms-transform: translate(-50%, -50%); -moz-transform: translate(-50%, -50%); -webkit-transform: translate(-50%, -50%); -o-transform: translate(-50%, -50%);"><div class="center-tip-content" style="width: 350px;"><div class="tip-close"></div><div class="exchange-popup-wrap"><h2>' + a + '</h2><p>' + b + '</p><a href="/" target="_blank" id="go-to-live">去看直播</a><input id="keep-here" type="button" value="留在当前页面"></div></div></div>');
}
})();