V2EX自动领取每日签到登录奖励

每天打开V2EX网站任意页面时自动领取签到的登陆奖励。

目前为 2014-07-20 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name V2EX自动领取每日签到登录奖励
  3. // @namespace http://userscripts.org/scripts/show/176989
  4. // @description 每天打开V2EX网站任意页面时自动领取签到的登陆奖励。
  5. // @icon http://ww1.sinaimg.cn/large/4ec98f50jw1e85azvlnh9j206y06y3ye.jpg
  6. // @author me
  7. // @include http*://*.v2ex.com/*
  8. // @include http*://v2ex.com/*
  9. // @version 2014.1.24
  10. // ==/UserScript==
  11.  
  12.  
  13. var load, execute, loadAndExecute;
  14. load = function(a, b, c) {
  15. var d;
  16. d = document.createElement("script"), d.setAttribute("src", a), b != null && d.addEventListener("load", b), c != null && d.addEventListener("error", c), document.body.appendChild(d);
  17. return d
  18. }, execute = function(a) {
  19. var b, c;
  20. typeof a == "function" ? b = "(" + a + ")();" : b = a, c = document.createElement("script"), c.textContent = b, document.body.appendChild(c);
  21. return c
  22. }, loadAndExecute = function(a, b) {
  23. return load(a, function() {
  24. return execute(b)
  25. })
  26. };
  27.  
  28. loadAndExecute("//ajax.aspnetcdn.com/ajax/jQuery/jquery-2.0.0.min.js", function() {
  29. if ( document.getElementById("money") && document.getElementById("money").getElementsByTagName("a")[0].href.indexOf("/balance") != -1 ) {
  30. function p(s) {return s < 10 ? '0' + s: s;} //自动补0
  31. var uid=document.getElementById("Rightbar").getElementsByTagName("a")[0].href.split("/member/")[1];
  32. var dateinfo=new Date().getUTCDate();
  33. var dateexp=new Date('2222-02-02').toGMTString();
  34. var cookiestr="IDINFO=:" + uid + ":" + dateinfo + ":";
  35. var date2="" + new Date().getUTCFullYear() + p(new Date().getUTCMonth()+1) +p(new Date().getUTCDate())
  36. //var daily = $('a[href="/mission/daily"]');
  37. var daily = $('input[id="q"]');
  38. if (daily.length && document.cookie.indexOf(cookiestr) == -1 ) {
  39. daily.val("正在检测每日签到状态...");
  40. $.ajax({
  41. url: "/mission/daily",
  42. success: function(data) {
  43. var awards = $(data).find('input[value^="领取"]');
  44. if (awards.length) {
  45. // daily.val("正在" + awards.attr("value") + "...");
  46. daily.val("正在领取今日的登录奖励......");
  47. $.ajax({
  48. url: awards.attr('onclick').match(/(?=\/).+?(?=\')/),
  49. success: function(data) {
  50. daily.val("正在提交...");
  51. var days=data.split("已连续登")[1].split(" ")[1];
  52. if ( $('a[href="/mission/daily"]').length==1 ) {$('a[href="/mission/daily"]').parent().parent().fadeOut(3000)}
  53. $.ajax({
  54. url: "/balance",
  55. success: function(data) {
  56. if (data.indexOf(date2+" 的每日登录奖励")!="-1") {
  57. daily.val( "已连续领取" + days + "天,本次领到" + data.split("每日登录")[2].split(" ")[1] + "铜币" );
  58. document.cookie =cookiestr + ";expires=" + dateexp;
  59. } else {
  60. daily.val( "自动领取遇到意外,你可以试试手动领。" );
  61. }
  62. }
  63. })
  64. },
  65. error: function() {
  66. daily.val("网络异常 :(");
  67. }
  68. });
  69. }else{
  70. if (data.indexOf("已领取") != -1) {
  71. daily.val("今日奖励领取过了");
  72. document.cookie =cookiestr + ";expires=" + dateexp;
  73. } else {
  74. daily.val("无法辩识领奖按钮 :(");
  75. }
  76.  
  77. }
  78. },
  79. error: function() {
  80. daily.val("请手动领取今日的登录奖励!");
  81. }
  82. });
  83. } else {
  84. console.log("Wish you a happy day :)");
  85. }
  86. }
  87. });