tiebagogo

常逛的贴吧快速切换

  1. // ==UserScript==
  2. // @name tiebagogo
  3. // @description 常逛的贴吧快速切换
  4. // @include http://www.baidu.com/*
  5. // @include http://tieba.baidu.com/*
  6. // @icon http://imgsrc.baidu.com/forum/pic/item/6fd108fb43166d229cb84fac452309f79152d2e2.png
  7. // @author congxz6688
  8. // @version 2014.12.1.0
  9. // @namespace https://gf.qytechs.cn/scripts/151
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13.  
  14. //此处供用户添加自己常逛的吧
  15. //贴吧名称不要带后面的“吧”字,就象下面的例子一样,用小写的双引号括起来,再用小写的逗号相互隔开
  16. var addByUser = ["宰执天下", "大宋的智慧", "chrome", "firefox", "行尸走肉", "疑犯追踪", "超感神探", "grimm"];
  17.  
  18. /**********************以下部分不要随意修改**********************/
  19.  
  20. function addStyle(css){
  21. document.head.appendChild(document.createElement("style")).textContent = css;
  22. }
  23.  
  24. var signCSS = "";
  25. signCSS += ".useColor{color:#1E6AD0;} .gogoTd{line-height:22px; padding:0px 8px;} .gogo{text-decoration:none} .gogo:hover{text-decoration:underline}";
  26. signCSS += "#floatGogo{border:1px solid grey; z-index:999; padding:8px 6px; background-color:white; color: blue;}";
  27. signCSS += "#tieba_gogo{cursor:pointer; color:blue; background_color:grey; height:14px; width:16px; padding:1px 5px 9px 4px; position:fixed; top:200px; left:0px; z-index:99999; border: solid 1px #1E6AD0;}"
  28. addStyle(signCSS);
  29.  
  30.  
  31. //函数 绝对定位
  32. function getElementLeft(element) {
  33. var actualLeft = element.offsetLeft;
  34. var current = element.offsetParent;
  35. while (current !== null) {
  36. actualLeft += current.offsetLeft;
  37. current = current.offsetParent;
  38. }
  39. return actualLeft;
  40. }
  41. //函数 绝对定位
  42. function getElementTop(element) {
  43. var actualTop = element.offsetTop;
  44. var current = element.offsetParent;
  45. while (current !== null) {
  46. actualTop += current.offsetTop;
  47. current = current.offsetParent;
  48. }
  49. return actualTop;
  50. }
  51. var Tds1 = [];
  52. //建表函数
  53. function creaseTable(UrlLength) {
  54. Tds1 = [];
  55. cons = 2;
  56. var tablepp = document.createElement("table");
  57. tablepp.setAttribute("width", "100%");
  58. var trs = [];
  59. for (ly = 0; ly < Math.ceil(UrlLength / cons); ly++) {
  60. var tr = document.createElement("tr");
  61. mmd = trs.push(tr);
  62. tablepp.appendChild(tr);
  63. }
  64. for (ls = 0; ls < UrlLength; ls++) {
  65. var td = document.createElement("td")
  66. td.setAttribute("class", "gogoTd");
  67. wq = Tds1.push(td);
  68. trs[Math.floor(ls / cons)].appendChild(td);
  69. }
  70. return tablepp
  71. }
  72.  
  73. //悬浮列表窗创建函数
  74. function openGogoList(e) {
  75. if (!document.getElementById("floatGogo")) {
  76. if ((e.target.getAttribute("href") && e.target.getAttribute("href") == "http://tieba.baidu.com") || (e.target.getAttribute("wdfield") && e.target.getAttribute("wdfield") == "kw")) {
  77. var jjue = e.target;
  78. var thisTop = getElementTop(jjue) + 15;
  79. } else if (e.target.id == "tieba_gogo"){
  80. var jjue = e.target;
  81. var thisTop = getElementTop(jjue) + 25;
  82. }else {
  83. var jjue = document.querySelector(".nav_item") || document.querySelector(".star_info>a") || document.getElementById("tab_home") || document.getElementsByClassName("card_title")[0] || document.getElementById("tab_forumname");
  84. var thisTop = getElementTop(jjue) + 30;
  85. }
  86. var thisLeft = getElementLeft(jjue);
  87. addStyle("#floatGogo{position:" + ((e.target.id == "tieba_gogo") ? "fixed" : "absolute") + "; left:" + thisLeft + "px; top:" + thisTop + "px}");
  88. var floatGogo = document.createElement("div");
  89. floatGogo.id = "floatGogo";
  90. var huuw = addByUser.deleteThe("贴吧例一").deleteThe("贴吧例二");
  91. var fTable = creaseTable(huuw.length);
  92. floatGogo.appendChild(fTable);
  93. if (huuw.length > 0) {
  94. for (vv = 0; vv < huuw.length; vv++) {
  95. var anch = document.createElement("a");
  96. anch.href = "http://tieba.baidu.com/f?kw=" + huuw[vv];
  97. anch.title = huuw[vv];
  98. anch.className = "gogo";
  99. anch.target = "_blank";
  100. anch.innerHTML = '<fon class="useColor">' + huuw[vv].reComLength() + '</fon>';
  101. Tds1[vv].appendChild(anch);
  102. }
  103. }
  104. floatGogo.addEventListener("mouseleave", closeGogoList, false)
  105. document.body.appendChild(floatGogo);
  106. }
  107. }
  108. function closeGogoList() {
  109. document.getElementById("floatGogo").parentNode.removeChild(document.getElementById("floatGogo"));
  110. }
  111. //吧名长度计算
  112. String.prototype.reComLength = function () {
  113. var yn = 0;
  114. var kuu = "";
  115. for (w in this) {
  116. if (w < this.length) {
  117. if (/[a-zA-Z0-9]/.exec(this[w])) {
  118. yn += 1;
  119. } else {
  120. yn += 2;
  121. }
  122. if (yn < 13) {
  123. kuu += this[w];
  124. }
  125. }
  126. }
  127. var uui = yn > 15 ? kuu + "..." : this;
  128. return uui;
  129. }
  130. //数组中删除特定元素
  131. Array.prototype.deleteThe = function (v) {
  132. var ra = [];
  133. for (w = 0; w < this.length; w++) {
  134. if (this[w] != v) {
  135. foo = ra.push(this[w]);
  136. }
  137. }
  138. return ra;
  139. }
  140. //数组中删除与另一数组重复的元素
  141. Array.prototype.deleteRepeatWith = function (v) {
  142. var ra = [];
  143. for (w = 0; w < this.length; w++) {
  144. if (v.indexOf(this[w]) == -1) {
  145. foo = ra.push(this[w]);
  146. }
  147. }
  148. return ra;
  149. }
  150.  
  151. var gogoDiv = document.createElement("div");
  152. gogoDiv.innerHTML = "go";
  153. gogoDiv.id = "tieba_gogo";
  154. gogoDiv.addEventListener("mouseover", openGogoList, false);
  155. if(window.location.href.match(/\/p\/|f\?ct=|f\?kz=/)){
  156. gogoDiv.addEventListener("click", function(){
  157. window.location = document.querySelector("#tofrs_up>a").href;
  158. }, false);
  159. }
  160. document.body.appendChild(gogoDiv);
  161. if (document.location.href.indexOf("www.baidu.com") == -1) {
  162. var refresh = document.querySelector(".nav_item") || document.querySelector(".star_info>a") || document.getElementsByClassName("card_title_fname")[0] || document.getElementById("tab_home") || document.getElementById("tab_forumname") || document.getElementsByClassName("signrank_crown_tab_text")[0];
  163. refresh.addEventListener("mouseover", openGogoList, false);
  164. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址