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

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

目前為 2015-08-16 提交的版本,檢視 最新版本

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