Greasy Fork

Greasy Fork is available in English.

x4的夺宝岛脚本

zh-cn

当前为 2015-10-14 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        x4的夺宝岛脚本
// @description zh-cn
// @namespace   jd.com
// @version     1.2
// @grant       none
// @homepageURL http://greasyfork.icu/zh-CN/scripts/13063-x4%E7%9A%84%E5%A4%BA%E5%AE%9D%E5%B2%9B%E8%84%9A%E6%9C%AC
// @include     http://paimai.jd.com/*
// ==/UserScript==
var sdiv = $('<div><b>最高出价<input id="maxpirce" type="text" maxlength="5" style="width:55px;">'
+ '<input type="checkbox" id="notestchujia">正式出价  | '
+ '监测间隔<input type="text" id="checkppp" value="100" style="width:25px;"></b>'
+ '<hr>倒计时:<span id="xxxtimes">0</span> | '
+ '我的出价:<b id="mypirce" style="color:#F00">0</b><hr></div>');
sdiv.css({
  'position': 'fixed',
  'top': '25px',
  'right': '10px',
  'width': '280px',
  'border': '2px solid #000',
  'z-index': '999',
  'background-color': 'rgb(221, 221, 221)',
  'padding': '5px'
});
$('body').append(sdiv);
var sbtn = $('<button>开始夺宝</btton>');
var ebtn = $('<button>停</btton>');
var cbtn = $('<button>测</btton>');
sdiv.append(ebtn);
sdiv.append(cbtn);
sdiv.append(sbtn);
sdiv.append('<hr><ul id="clog"></ul>');
cbtn.click(function () {
  var num = 0;
  var allys = 0;
  $('#clog').empty();
  var ttt = setInterval(function () {
    var now = new Date().getTime();
    $.getJSON('http://paimai.jd.com/json/current/englishquery?paimaiId=' + paimaiId + '&skuId=0&start=0&end=1', function (data) {
      var cbk = new Date().getTime();
      num++;
      $('#clog').append('<li>第' + num + '次测试: 延时 ' + (cbk - now) + ' ms</li>');
      allys += (cbk - now);
      if (num >= 10) {
        clearInterval(ttt);
        $('#clog').append('<li><b>10次平均: 延时 ' + (allys / 10) + ' ms</b></li>');
      }
    });
  }, 300);
});

sbtn.click(function () {
  var runtimer;
  sbtn.text('监测中..竞拍编号:' + paimaiId);
  var checktimess = parseInt($('#checkppp').val());
  var mypirce = 0;
  var chujianum = 0;
  $('#clog').empty();
  $.getJSON('http://paimai.jd.com/json/current/englishquery?paimaiId=' + paimaiId + '&skuId=0&start=0&end=1', function (data) {
    $('#clog').append('<li>校准时间:' + data.remainTime + 'ms 当前价:' + data.currentPrice + '</li>');
    remainTime = data.remainTime;
    var ssstrat = remainTime % checktimess;
    var ttimenum = remainTime - ssstrat;
    var nowjia = 0; //当前加价幅度
    var oldjia = 0; //上次价
    setTimeout(function () {
      runtimer = setInterval(function () {
        ttimenum = ttimenum - checktimess;
        $('#xxxtimes').text((ttimenum / 1000).toFixed(4) + ' ms');
        // 自动关闭弹窗提示
        if ($('.ui-dialog').size()) {
          $('#clog').append('<li>弹窗:' + $('.ui-dialog').find('.jbox-content').text() + '</li>');
          $('.ui-dialog,.ui-mask').remove();
        };
        // 2000毫秒开始监测价格
        if (ttimenum <= 2000) {
          // 请求json
          var nowttt = new Date().getTime();
          $.getJSON('http://paimai.jd.com/json/current/englishquery?paimaiId=' + paimaiId + '&skuId=0&start=0&end=1', function (data) {
            var cbkttt = new Date().getTime() - nowttt;
            var nowp = parseInt(data.currentPrice);
            if (oldjia != 0) nowjia = nowp - oldjia;
            if (oldjia == 0 && oldjia != nowp) oldjia = nowp;
            ttimenum = data.remainTime;
            // 夺宝完毕
            if (ttimenum == '-1') {
              if ($('#endduobao').size() == 0) {
                $('#clog').append('<li id="endduobao">夺宝完毕!! (' + data.currentPrice + '|' + data.remainTime + ')</li>');
                sbtn.text('开始夺宝');
              }
              runtimer = clearInterval(runtimer);
              return false;
            };
            var myygcj = nowp + nowjia + 1;
            $('#clog').append('<li>时:' + data.remainTime
            + ' 价:' + parseInt(data.currentPrice)
            + ' 延:' + cbkttt
            + ' 幅:' + nowjia
            + ' 需:' + myygcj + '</li>');
            // 出价时点
            if (ttimenum <= (1050 + cbkttt + checktimess)) {
              if ($('#cjtimenow').size() == 0) $('#clog').append('<hr><li id="cjtimenow" style="color:#F00">出价时点 >>> (' + data.remainTime + ' | <b>' + myygcj + '</b>)</li>');
              // 出价判断
              if (myygcj <= parseInt($('#maxpirce').val()) && mypirce < nowp) {
                //
                // 加价幅度
                mypirce = myygcj;
                //
                //
                $('#mypirce').text(mypirce + '|' + data.remainTime);
                $('#bidPrice').val(mypirce);
                // 正式或测试出价
                if (mypirce <= parseInt($('#maxpirce').val()) && $('#notestchujia').prop('checked') == true) {
                  $('#clog').append('<li style="color:#F00">正式出价 >>> (' + mypirce + '|' + data.remainTime + ')</li>');
                  var url = '/services/bid.action?t=' + getRamdomNumber();
                  var data = {
                    paimaiId: paimaiId,
                    price: mypirce,
                    proxyFlag: 0,
                    bidSource: 0
                  };
                  jQuery.getJSON(url, data, function (jqXHR) {
                    if (jqXHR.result == '200') {
                      $('#clog').append('<li  style="color:#F00">出价成功!(' + mypirce + ')</li>');
                    } else {
                      $('#clog').append('<li>' + jqXHR.result + ' ' + jqXHR.message + '</li>');
                    }
                  });
                } else {
                  $('#clog').append('<li style="color:#F00">测试出价 >>> (' + mypirce + '|' + data.remainTime + ')</li>');
                }
              }
              // 出价判断完毕

            }
          }); // 请求json完毕          
        }
      }, checktimess); // 多少毫秒监测一次
    }, ssstrat); //修正延时
  });
  ebtn.one('click', function () {
    sbtn.text('开始夺宝');
    runtimer = clearInterval(runtimer);
  });
});

var dragging = false;
var iX,iY;
sdiv.mousedown(function (e) {
  dragging = true;
  iX = e.clientX - this.offsetLeft;
  iY = e.clientY - this.offsetTop;
  this.setCapture && this.setCapture();
//   return false;
});
document.onmousemove = function (e) {
  if (dragging) {
    var e = e || window.event;
    var oX = e.clientX - iX;
    var oY = e.clientY - iY;
    sdiv.css({
      'left': oX + 'px',
      'top': oY + 'px'
    });
    return false;
  }
};
$(document).mouseup(function (e) {
  dragging = false;
  e.cancelBubble = true;
});