Greasy Fork 支持简体中文。

V2EX增强插件

1.回复标记楼主ID 2.每天打开V2EX网站任意页面时自动领取签到的登陆奖励 3.回复时可@所有人 4.召唤/呼叫管理员 5.链接自动转图片

目前為 2024-01-08 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name V2EX增强插件
  3. // @description 1.回复标记楼主ID 2.每天打开V2EX网站任意页面时自动领取签到的登陆奖励 3.回复时可@所有人 4.召唤/呼叫管理员 5.链接自动转图片
  4. // @namespace yfmx746qpx8vhhmrgzt9s4cijmejj3tn
  5. // @icon http://ww1.sinaimg.cn/large/4ec98f50jw1e85azvlnh9j206y06y3ye.jpg
  6. // @author me
  7. // @include https://*.v2ex.com/*
  8. // @include https://v2ex.com/*
  9. // @version 2024.01.08
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. // 2024.01.08 更新管理员列表
  14. // 2023.12.27 避免链接转图片的大小超出布局
  15. // 2021.11.26 账户余额页面增加签到页面链接
  16. // 2020.10.19 首页增加全文搜索链接
  17. // 2020.10.10 解决由于改版导致的定位错误导致无法签到问题
  18. // 2019.10.25 解决Safari不能重加载新浪图片
  19. // 2019.08.01 修正帖子tag区域的链接转图片误判
  20. // 2019.05.12 新浪的图片反防盗链
  21. // 2017.05.16 由于存储数据出错,改变存储数据的方式
  22. // 2016.09.21 修复发帖页面判断用户名出错的情况
  23. // 2016.09.14 修正判断登录状态逻辑
  24. // 2016.05.25 链接自动转图片
  25. // 2016.05.21 新增召唤/呼叫管理员
  26. // 2016.05.09 Webkit内核允许修改回复框高度
  27. // 2016.04.12 在回复时可@所有人
  28. // 2015.10.16 新增在回复中标记楼主
  29. // 2015.03.22 尝试修正未知原因情况下导致的签到失败。
  30. // 2015.02.07 解决JQuery库在某种情况可能会无法载入
  31. // 2014.10.07 某种情况下会产生cookie重复赋值,增加清理补丁。
  32. // 2014.10.06 cookie信息过期时间改为3天
  33.  
  34.  
  35. //签到
  36. (function(){
  37. var load, execute, loadAndExecute;
  38. load = function(a, b, c) {
  39. var d;
  40. d = document.createElement("script"), d.setAttribute("src", a), b != null && d.addEventListener("load", b), c != null && d.addEventListener("error", c), document.body.appendChild(d);
  41. return d;
  42. }, execute = function(a) {
  43. var b, c;
  44. typeof a == "function" ? b = "(" + a + ")();" : b = a, c = document.createElement("script"), c.textContent = b, document.body.appendChild(c);
  45. return c;
  46. }, loadAndExecute = function(a, b) {
  47. return load(a, function() {
  48. return execute(b);
  49. });
  50. };
  51.  
  52. loadAndExecute("//lib.sinaapp.com/js/jquery/2.0/jquery.min.js", function() {
  53. if ( $("a[class='balance_area']").length > 0 && $("a[href='/settings']").length > 0 ) {
  54. var uid=$.find('a[href^="/member/"]')[0].innerHTML;//用户名
  55. var dateinfo=new Date().getUTCDate();//获得GMT时间今天几号
  56. var SigninInfo=uid + ":" + dateinfo + "";
  57. var daily = $('input[id="search"]');
  58. if (daily.length && localStorage.SigninInfo != SigninInfo ) {
  59. $.ajax({url:"/"});
  60. daily.val("正在检测每日签到状态...");
  61. $.ajax({
  62. url: "/mission/daily",
  63. success: function(data) {
  64. var awards = $(data).find('input[value^="领取"]');
  65. if (awards.length) {
  66. // daily.val("正在" + awards.attr("value") + "...");
  67. daily.val("正在领取今日的登录奖励......");
  68. $.ajax({
  69. url: awards.attr('onclick').match(/(?=\/).+?(?=\')/),
  70. success: function(data) {
  71. daily.val("正在提交...");
  72. var days=data.split("已连续登")[1].split(" ")[1];
  73. if ( $('a[href="/mission/daily"]').length==1 ) {$('a[href="/mission/daily"]').parent().parent().fadeOut(3000);}
  74. $.ajax({
  75. url: "/balance",
  76. success: function(data) {
  77. function p(s) {return s < 10 ? '0' + s: s;} //自动补0
  78. var date2="" + new Date().getUTCFullYear() + p(new Date().getUTCMonth()+1) +p(new Date().getUTCDate());
  79. if (data.indexOf(date2+" 的每日登录奖励")!="-1") {
  80. daily.val( "已连续领取" + days + "天,本次领到" + data.split("每日登录")[2].split(" ")[1] + "铜币" );
  81. localStorage.SigninInfo = SigninInfo;
  82. } else {
  83. daily.val( "自动领取遇到意外,你可以试试手动领。" );
  84. }
  85. }
  86. });
  87. },
  88. error: function() {
  89. daily.val("网络异常 :(");
  90. }
  91. });
  92. }else{
  93. if (data.indexOf("已领取") != -1) {
  94. daily.val("今日奖励领取过了");
  95. localStorage.SigninInfo = SigninInfo;
  96. } else {
  97. daily.val("无法辩识领奖按钮 :(");
  98. }
  99.  
  100. }
  101. },
  102. error: function() {
  103. daily.val("请手动领取今日的登录奖励!");
  104. }
  105. });
  106. } else {
  107. //console.log("");
  108. }
  109. }
  110. });
  111. })();
  112.  
  113. //标记楼主(废弃),回复所有人
  114. (function (){
  115. return;//(废弃)
  116. var uid=document.getElementById("Rightbar").getElementsByTagName("a")[0].href.split("/member/")[1];//自己用户名
  117. if (location.href.indexOf(".com/t/") != -1) {
  118. var lzname=document.getElementById("Main").getElementsByClassName("avatar")[0].parentNode.href.split("/member/")[1];
  119. var allname='@'+lzname+' ';
  120. var all_elem = document.getElementsByClassName("dark");
  121. for(var i=0; i<all_elem.length; i++) {
  122. if (all_elem[i].innerHTML == lzname){
  123. //all_elem[i].innerHTML += " <font color=green>[楼主]</font>";
  124. }
  125. //为回复所有人做准备
  126. if ( uid != all_elem[i].innerHTML && all_elem[i].href.indexOf("/member/") != -1 && all_elem[i].innerText == all_elem[i].innerHTML && allname.indexOf('@'+all_elem[i].innerHTML+' ') == -1 ) {
  127. allname+='@'+ all_elem[i].innerHTML+' ';
  128. }
  129. }
  130. }
  131.  
  132. if ( document.getElementById("reply_content") ) {
  133. document.getElementById("reply_content").parentNode.innerHTML+="&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:;' onclick='if ( document.getElementById(\"reply_content\").value.indexOf(\""+allname+"\") == -1 ) {document.getElementById(\"reply_content\").value+=\"\\r\\n"+allname+"\"}'>@所有人</a>";
  134. if ( document.body.style.WebkitBoxShadow !== undefined ) {
  135. //允许调整回复框高度
  136. document.getElementById("reply_content").style.resize="vertical";
  137. }
  138. document.getElementById("reply_content").style.overflow="auto";
  139. var magagers="@Livid @Kai @Olivia @GordianZ @sparanoid @Tink";
  140. document.getElementById("reply_content").parentNode.innerHTML+="&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:;' onclick='if ( document.getElementById(\"reply_content\").value.indexOf(\""+magagers+"\") == -1 ) {document.getElementById(\"reply_content\").value+=\"\\r\\n"+magagers+"\"}'>@管理员</a>";
  141. }
  142. })();
  143.  
  144. // 图片链接自动转换成图片 代码来自caoyue@v2ex
  145. (function (){
  146. var links = document.links;
  147. for (var i=0;i<links.length;i++){
  148. var link = links[i];
  149. if (/^http.*\.(?:jpg|jpeg|jpe|bmp|png|gif)/i.test(link.href)
  150. && !/<img\s/i.test(link.innerHTML) && link.href.indexOf("v2ex.com/tag")==-1){
  151. link.innerHTML = "<img title='" + link.href + "' src='" + link.href + "' style='max-width:98%' />";
  152. }
  153. }
  154. })();
  155. //
  156.  
  157. //新浪图床的图片反防盗链
  158. (function (){
  159. var images = document.images;
  160. for (var i=0;i<images.length;i++){
  161. var image = images[i];
  162. if ( image.src && image.src.indexOf(".sinaimg.cn")!=-1 &&image.src.indexOf(".sinaimg.cn")<13 ) {
  163. image.setAttribute("referrerPolicy","no-referrer");
  164. image.src=image.src + "?";
  165. }
  166. }
  167. })();
  168. //
  169.  
  170. // 增加全文搜索链接
  171. if ( $('div[id="SecondaryTabs"]').length > 0 ) {
  172. document.getElementById("SecondaryTabs").innerHTML+='&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://www.sov2ex.com/" >全文搜索</a>'
  173. }
  174. //
  175.  
  176. // 在账户余额界面/明细界面的上方增加签到页面链接
  177. if ( location.href.indexOf("/balance") != -1 && document.getElementsByClassName("tab").length > 0) {
  178. document.getElementsByClassName("tab")[0].parentNode.innerHTML+='<a class="tab" href="/mission/daily" >签到</a>'
  179. }
  180. //