Greasy Fork

Greasy Fork is available in English.

杂兵专用活动领取器

try to take over the world!

当前为 2020-08-14 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

/*
 * @Author: tian.gao
 * @Date: 2020-08-14 11:03:26
 * @LastEditors: tian.gao
 * @LastEditTime: 2020-08-14 16:25:34
 * @Description:
 */
// ==UserScript==
// @name         杂兵专用活动领取器
// @namespace    http://tampermonkey.net/
// @version      0.11
// @description  try to take over the world!
// @author       You
// @match        *://wg-event.9you.com/*
// @grant        GM_xmlhttpRequest
// @grant        GM_download
// ==/UserScript==
(function() {
   // 活动信息
   var posJosn=[]
    const pages=`<div class="mys-page">
    <button class="lin" >
      一键领取
    </button>
    <div class="sid">

    </div>
  </div>`
  $(".main").append(pages)
  var style = document.createElement("style");
  style.type = "text/css";
  var text = document.createTextNode(`  .mys-page{
    width: 200px;
    height: 500px;
    position: fixed;
    right: 10px;
    top: 200px;
    background-color: #fff;
    overflow: scroll;
    z-index:9999
  }
  .lin{
    width: 200px;
    height: 30px;
    background-color: #a6dfa8;
  }`); /* 这里编写css代码 */
  style.appendChild(text);
  var head = document.getElementsByTagName("head")[0];
  head.appendChild(style);
  // 从码云上获取活动信息
  GM_xmlhttpRequest({
  method: "GET",
  url: "http://gaotianvb.gitee.io/mobile_soldier_ol__json/py.json",
  onload: function(response) {
     let a=response.response
     posJosn=JSON.parse(a)
    }
  });
  //$.ajaxSettings.async = false; //关闭异步
  // 请求池
  let postlist=[]
  // 请求池中添加请求
  function post(a1,a2) {
    postlist.push([a1,a2])
  }

  // 从请求池获取请求参数并请求
  setInterval(() => {
    if(postlist.length){
      let quer=postlist.shift()
      $.post(quer[0],quer[1],function(result){
      let res=JSON.parse(result)
    $('.sid').prepend('<p>'+res.desc+'</p>')
  })
    }
   //请求间隔,防止过快请求导致被网站屏蔽
  }, 500);
  $('.lin').click(function () {
      // 遍历活动信息,解析成请求参数


      // ["http://wg-event.9you.com/msact_202017946/do10", {"itemkey": "1"},[1, 5]]
      // 活动信息一般像上面的样子,第一个是请求url,第二个是请求参数,第三个是参数的范围
      // 例如"http://wg-event.9you.com/msact_202017946/do10", {"itemkey": "1"}
      //     "http://wg-event.9you.com/msact_202017946/do10", {"itemkey": "2"}
      //     "http://wg-event.9you.com/msact_202017946/do10", {"itemkey": "3"}
      // 像这样一个url 不同的itemkey对应同个活动的不同按钮  [1,5]表示1-5
      for (let i = 0; i < posJosn.length; i++) {
        const element = posJosn[i];
        if(element[2]){
          let key=Object.keys(element[1])
          for (let x = element[2][0]; x <= element[2][1]; x++) {
            let q={}
            if(element[3]){
              for (let y = element[3][0]; y <= element[3][1]; y++) {
                q[key[0]]=x
                q[key[1]]=y
                // sleep(1000)
                post(element[0],q)
              }
            }else{
              q[key[0]]=x
              // sleep(1000)
              post(element[0],q)
            }

          }
        }else{
          // sleep(1000)
          post(element[0],element[1])
          // $.post(element[0],element[1])
        }
      }
      // $.post("http://wg-event.9you.com/msact_202017912/do10",{itemkey: '1,3,4,5,8'})
  })


    // Your code here...
})();