V2EX.js

V2EX助手

目前为 2017-08-27 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name V2EX.js
  3. // @namespace http://zhihaofans.com
  4. // @version 0.6.0
  5. // @description V2EX助手
  6. // @author zhihaofans
  7. // @match https://www.v2ex.com/*
  8. // @grant none
  9. // @icon https://www.v2ex.com/static/img/icon_rayps_64.png
  10. // ==/UserScript==
  11. $(document).ready(function() {
  12. //搜索改为百度
  13. $("#Search form").submit(function() {
  14. var q = $("#q");
  15. if (q.val() !== "") {
  16. var url = "https://www.baidu.com/s?wd=site:v2ex.com%20" + q.val();
  17. if (navigator.userAgent.indexOf('iPad') > -1 || navigator.userAgent.indexOf('iPod') > -1 || navigator.userAgent.indexOf('iPhone') > -1) {
  18. location.href = url;
  19. } else {
  20. window.open(url, "_blank");
  21. }
  22. return false;
  23. } else {
  24. return false;
  25. }
  26. });
  27. var nowurl = location.pathname;
  28. //超链接改为新标签打开
  29. if (nowurl == "/" || nowurl.substr(0, 6) == "/?tab=" || nowurl.substr(0, 4) == "/go/" || nowurl == "/recent") {
  30. $("span.item_title a").attr("target", "_blank");
  31. }
  32. //楼主标记
  33. if (nowurl.substr(0, 3) == "/t/") {
  34. $("a[rel=nofollow]").attr("target", "_blank");
  35. $(".inner a").attr("target", "_blank");
  36. $(".inner:first a").removeAttr("target");
  37. var lzname = $(".header .gray a").text();
  38. var replynum = $("div.cell[id^=r_] strong a").length;
  39. for (var aa = 0; aa < replynum; aa++) {
  40. // console.log($("div.cell[id^=r_]:eq("+aa+") strong a").text());
  41. if ($("div.cell[id^=r_]:eq(" + aa + ") strong a").text() == lzname) {
  42. $("div.cell[id^=r_]:eq(" + aa + ") strong").html($("div.cell[id^=r_]:eq(" + aa + ") strong").html() + "&nbsp;[楼主]");
  43. }
  44. }
  45. }
  46. //屏蔽右侧广告
  47. $("#Rightbar .box .sidebar_compliance").parent().hide();
  48. //原搜索删除
  49. $("#Search form").removeAttr("onsubmit");
  50. });