Damai

try to take over the world!

2019-07-18 يوللانغان نەشرى. ئەڭ يېڭى نەشرىنى كۆرۈش.

// ==UserScript==
// @name         Damai
// @namespace    http://tampermonkey.net/
// @version      0.2.3 - Bham Init
// @description  try to take over the world!
// @author       Mr.FireAwayH
// @match        https://detail.damai.cn/item.htm*
// @run-at       document-end
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    var dates = [];
    var itemId = 0;
    var performId = 0;
    var skuId = 0;

    var priceHandler = function(e){
        skuId = e.target.value;
        var node = document.querySelector(".perform__order__box");
        if(window.enter){
            node.removeChild(window.enter);
        }
        if(skuId > -1){
            var selectSeat = document.querySelector(".service").innerText.indexOf("不支持选座") === -1;
            var enterButtonHTML = "";
            if(selectSeat){
                enterButtonHTML = `<a id='enter' href='https://seatsvc.damai.cn/tms/selectSeat?itemId=${itemId}&performId=${performId}&skuId=${skuId}&projectId=${itemId}&spm=a2oeg.project.projectinfo.dbuy' target='_blank'>点这里</a>`;
            }else{
                var num = document.querySelector(".cafe-c-input-number-input-wrap input").value;
                enterButtonHTML = `<a id='enter' href='https://buy.damai.cn/orderConfirm?exParams=%7B%22damai%22%3A%221%22%2C%22channel%22%3A%22damai_app%22%2C%22umpChannel%22%3A%2210002%22%2C%22atomSplit%22%3A%221%22%2C%22serviceVersion%22%3A%221.8.5%22%7D&buyParam=${itemId}_${num}_${skuId}&buyNow=true&spm=a2oeg.project.projectinfo.dbuy' target='_blank'>点这里</a>`;
            }
            var enterButton = document.createElement("a");
            node.appendChild(enterButton);
            enterButton.outerHTML = enterButtonHTML;
        }else{
            node.removeChild(window.enter);
        }
    }

    var dateHandler = function(e){
        var value = e.target.value;
        var node = document.querySelector(".perform__order__box");
        if(window.prices){
            node.removeChild(window.prices);
        }
        if(value > -1){
            var priceSelectHTML = "<select id='prices'><option value='-1'>请选择票价</option>";
            var perform = dates[value];
            itemId = perform.itemId;
            performId = perform.performId;

            perform.skuList.forEach(n => {
                priceSelectHTML += `<option value="${n.skuId}">${n.skuName}</option>`;
            });
            priceSelectHTML += "</select>";
            var priceSelect = document.createElement("select");
            node.appendChild(priceSelect);
            priceSelect.outerHTML = priceSelectHTML;
            window.prices.onchange = priceHandler;
        }else{
            node.removeChild(window.prices);
        }
    }

    var setup = function(){
        document.body.removeChild(window.hint);
        var data = JSON.parse(window.dataDefault.innerText).performBases;
        dates = data.map(s => s.performs.flat()).flat();

        var dateSelectHTML = "<span style='background: red; color: white; '>看这里</span><select id='performs'><option value='-1'>请选择日期</option>";
        dates.map(s => s.performName).forEach((n, i) => {
            dateSelectHTML += `<option value="${i}">${n}</option>`;
        });
        dateSelectHTML += "</select>";

        var dateSelect = document.createElement("select");
        document.querySelector(".perform__order__box").appendChild(dateSelect);
        dateSelect.outerHTML = dateSelectHTML;
        window.performs.onchange = dateHandler;
    }

    var init = function(){
        var a = document.createElement("div");
        document.body.appendChild(a);
        a.outerHTML = "<div id='hint' style='position: absolute;width: 30%;background: red;top: 40%;text-align: center;left: 40%;color: white;font-size: 40px;'>抢票辅助工作中</div>";
        setTimeout(setup, 5000);
    }

    window.onload = init;
})();
长期地址
遇到问题?请前往 GitHub 提 Issues,或加Q群1031348184

赞助商

Fishcpy

广告

Rainyun

注册一下就行

Rainyun

一年攒够 12 元