tieba_At_Ta

百度贴吧@它

目前為 2014-03-05 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name tieba_At_Ta
  3. // @description 百度贴吧@它
  4. // @include http://tieba.baidu.com/*
  5. // @exclude http://tieba.baidu.com/mo/*
  6. // @exclude http://tieba.baidu.com/i/*
  7. // @exclude http://tieba.baidu.com/f/like*
  8. // @exclude http://tieba.baidu.com/club/*
  9. // @exclude http://tieba.baidu.com/shipin/*
  10. // @exclude http://tieba.baidu.com/bakan*
  11. // @exclude http://tieba.baidu.com/daquan*
  12. // @exclude http://tieba.baidu.com/f/tupian*
  13. // @exclude http://tieba.baidu.com/tb/*
  14. // @exclude http://tieba.baidu.com/*postBrowserBakan*
  15. // @icon http://tb.himg.baidu.com/sys/portraitn/item/4e2ed7f8bbb3d4f2c2d2bb21
  16. // @author congxz6688
  17. // @version 2013.10.27.0
  18. // @namespace https://gf.qytechs.cn/scripts/153
  19. // ==/UserScript==
  20.  
  21.  
  22.  
  23. //下面这一段CSS,可帮助编辑器工具栏不够用的同学,没有这个需要的同学可删除它。
  24. var forCss2er = ".cut_screen{display:none!important;}";
  25. forCss2er += ".tb-editor-wrapper{width:720px !important}";
  26. forCss2er += ".recentImgDiv>.tb-editor-overlay{left:28% !important; top:30px !important;} .arrow.down{left: 218px !important;}";
  27. GM_addStyle(forCss2er);
  28.  
  29. //脚本主css
  30. var replyCss = "";
  31. replyCss += ".tb_icon_author, .tb_icon_author_rely{background:none !important;background-position:none !important; white-space:nowrap !important;}";
  32. replyCss += ".insertAt{padding:0px 0px 0px 0px; margin:1px 1px; cursor:pointer; background-color:lightGrey; display:inline-block;}";
  33. replyCss += "#attaDiv{background-color:lightGrey; width:450px; border:4px double gray;} #ATTAnewEditDiv *:not(.pageTitle){font-size:12px !important;}";
  34. replyCss += ".leftDiv{display:inline-block; background-color:lightGrey;padding:5px 6px; width:48px;}";
  35. replyCss += ".rightDiv{display:inline-block; background-color:lightGrey; padding:4px 6px; width:375px;}";
  36. replyCss += ".addPlus{cursor:pointer; margin:0px 2px 0px 0px; width:20px; color:blue;}";
  37. replyCss += ".addPlusBack{cursor:pointer; margin:0px 2px 0px 0px; width:20px; color:red;}";
  38. replyCss += ".picFrd{cursor:pointer; margin:0px 2px 0px -1px; width:20px; color:#A0522D; font-size:13px} .bbaa{cursor:pointer; margin:0px 2px 0px -1px; width:20px; color:green; font-size:13px} .bbaaB{cursor:pointer; margin:0px 2px 0px -1px; width:20px; color:#1E90FF; font-size:13px}";
  39. replyCss += ".picFrdTab{cursor:pointer; margin:0px 2px 0px 2px; width:20px; color:#A0522D;} .bbaaTab{cursor:pointer; margin:0px 2px 0px 2px; width:20px; color:green;} .bbaaTabB{cursor:pointer; margin:0px 2px 0px 2px; width:20px; color:#1E90FF;}";
  40. replyCss += ".addPlusTab{cursor:pointer; margin:0px 2px 0px 2px; width:20px; color:blue;}";
  41. replyCss += ".addPlusTabBack{cursor:pointer; margin:0px 2px 0px 2px; width:20px; color:red;}";
  42. replyCss += ".closeDivbt{cursor:pointer; float:right; margin:0px -2px; width:16px; height:16px;}";
  43. replyCss += "#atta{cursor:pointer; margin:0 0 0 12px; display:inline-block; color:#3163B6; padding: 1px 1px 10px 1px; position:relative; top:0px}";
  44. replyCss += "#atta_lzl{margin:0 5px 3px 5px; float:right;cursor:pointer; font-size:1.2em; display:inline-block; color:#3163B6;}";
  45. replyCss += ".thread_alt>td:nth-child(4){width:110px} .thread_alt>td:nth-child(5){width:160px}";
  46. replyCss += ".ATeditFaceTxtTb{width:150px; padding:1px 1px 0 0;} .inputInTd{width:149px;} .FTbutton{margin:10px 10px 0px 0px}";
  47. replyCss += "#ATTAnewEditDiv{border: 1px solid gray; z-index:2000; background-color:#EEEEEE; padding:20px; position:fixed; left:300px; bottom:80px;}";
  48. replyCss += ".pageTitle{font-size : 16px; margin-bottom : 15px;}";
  49. GM_addStyle(replyCss);
  50.  
  51. var $ = unsafeWindow.$;
  52. var Tds = []; //数据修改用列表
  53. var thisPageTitle = document.getElementById("wd1").value + "吧";
  54.  
  55. //脚本双存储数据相互恢复
  56. if (!localStorage.myBaFriends && GM_getValue("myBaFriends", "") != "") {
  57. localStorage.myBaFriends = GM_getValue("myBaFriends");
  58. }
  59. if (GM_getValue("myBaFriends", "") == "" && localStorage.myBaFriends) {
  60. GM_setValue("myBaFriends", localStorage.myBaFriends);
  61. }
  62. if (!localStorage.publicFriends && GM_getValue("publicFriends", "") != "") {
  63. localStorage.publicFriends = GM_getValue("publicFriends");
  64. }
  65. if (GM_getValue("publicFriends", "") == "" && localStorage.publicFriends) {
  66. GM_setValue("publicFriends", localStorage.publicFriends);
  67. }
  68.  
  69. //函数 数组字符串重排序
  70. String.prototype.reIndexStr = function () {
  71. var lastSt = this.split(",");
  72. var lastStr = lastSt.sort(function (a, b) {
  73. return a.localeCompare(b)
  74. });
  75. return lastStr;
  76. }
  77.  
  78. //长ID缩略显示
  79. String.prototype.reComLength = function () {
  80. var yn = 0;
  81. var kuu = "";
  82. for (w in this) {
  83. if (w < this.length) {
  84. if (/[a-zA-Z0-9]/.exec(this[w])) {
  85. yn += 1;
  86. } else {
  87. yn += 2;
  88. }
  89. if (yn < 13) {
  90. kuu += this[w];
  91. }
  92. }
  93. }
  94. var uui = yn > 14 ? kuu + "..." : this;
  95. return uui;
  96. }
  97. //元素精确监听
  98. function addNodeInsertedListener(elCssPath, handler, executeOnce, noStyle) {
  99. var animName = "anilanim",
  100. prefixList = ["-o-", "-ms-", "-khtml-", "-moz-", "-webkit-", ""],
  101. eventTypeList = ["animationstart", "webkitAnimationStart", "MSAnimationStart", "oAnimationStart"],
  102. forEach = function (array, func) {
  103. for (var i = 0, l = array.length; i < l; i++) {
  104. func(array[i]);
  105. }
  106. };
  107. if (!noStyle) {
  108. var css = elCssPath + "{",
  109. css2 = "";
  110. forEach(prefixList, function (prefix) {
  111. css += prefix + "animation-duration:.001s;" + prefix + "animation-name:" + animName + ";";
  112. css2 += "@" + prefix + "keyframes " + animName + "{from{opacity:.9;}to{opacity:1;}}";
  113. });
  114. css += "}" + css2;
  115. GM_addStyle(css);
  116. }
  117. if (handler) {
  118. var bindedFunc = function (e) {
  119. var els = document.querySelectorAll(elCssPath),
  120. tar = e.target,
  121. match = false;
  122. if (els.length !== 0) {
  123. forEach(els, function (el) {
  124. if (tar === el) {
  125. if (executeOnce) {
  126. removeNodeInsertedListener(bindedFunc);
  127. }
  128. handler.call(tar, e);
  129. return;
  130. }
  131. });
  132. }
  133. };
  134. forEach(eventTypeList, function (eventType) {
  135. document.addEventListener(eventType, bindedFunc, false);
  136. });
  137. return bindedFunc;
  138. }
  139. }
  140. //移除精确监听
  141. function removeNodeInsertedListener(bindedFunc) {
  142. var eventTypeList = ["animationstart", "webkitAnimationStart", "MSAnimationStart", "oAnimationStart"],
  143. forEach = function (array, func) {
  144. for (var i = 0, l = array.length; i < l; i++) {
  145. func(array[i]);
  146. }
  147. };
  148. forEach(eventTypeList, function (eventType) {
  149. document.removeEventListener(eventType, bindedFunc, false);
  150. });
  151. }
  152. //获取本吧各数组
  153. function thisBaArray(ww) {
  154. if (ww == "publicFriends") {
  155. var bbarray = (localStorage.publicFriends) ? localStorage.publicFriends.split(",") : [];
  156. } else {
  157. var getBazhu = JSON.parse((localStorage[ww]) ? localStorage[ww] : "{}");
  158. var bbarray = getBazhu[thisPageTitle] ? getBazhu[thisPageTitle] : [];
  159. }
  160. return bbarray
  161. }
  162. //函数 载入各名单
  163. function loadThe(ww) {
  164. switch (ww) {
  165. case "myBaFriends":
  166. $("#td22div").empty();
  167. var parentDiv = document.getElementById("td22div");
  168. break;
  169. case "bigBaToday":
  170. var parentDiv = document.getElementById("td12div");
  171. break;
  172. case "smallBaToday":
  173. var parentDiv = document.getElementById("td42div");
  174. break;
  175. case "publicFriends":
  176. $("#td32div").empty();
  177. var parentDiv = document.getElementById("td32div");
  178. break;
  179. }
  180. if (thisBaArray(ww).length != 0) {
  181. myFri = thisBaArray(ww).toString().reIndexStr();
  182. for (l = 0; l < myFri.length; l++) {
  183. var ddoi = document.createElement("span");
  184. ddoi.innerHTML = "&nbsp;@" + myFri[l] + "&nbsp;";
  185. ddoi.className = "insertAt";
  186. ddoi.addEventListener("click", insertEdiror, false);
  187. parentDiv.appendChild(ddoi);
  188. }
  189. }
  190. }
  191.  
  192. //函数 插入到编辑器
  193. function insertEdiror(e) {
  194. var InsertText = e.target.innerHTML;
  195. var editor = (localStorage['which_editor']) ? localStorage['which_editor'] : 'atta';
  196. (editor == "atta") ? unsafeWindow.test_editor.execCommand("inserthtml", InsertText) : unsafeWindow.LzlEditor._s_p._se.execCommand("inserthtml", InsertText);
  197. closeAttable();
  198. }
  199. //函数 这是隐藏的福利,我会说吗?
  200. function insertAll(e) {
  201. var idd = e.target.id;
  202. which_ed = (localStorage['which_editor']) ? localStorage['which_editor'] : 'atta';
  203. var bazhuST = "";
  204. switch (idd) {
  205. case "td42div":
  206. var lmo = thisBaArray("smallBaToday");
  207. break;
  208. case "td12div":
  209. var lmo = thisBaArray("bigBaToday");
  210. break;
  211. case "td22div":
  212. var lmo = thisBaArray("myBaFriends");
  213. break;
  214. case "td32div":
  215. var lmo = thisBaArray("publicFriends");
  216. break;
  217. }
  218. if (lmo.length != 0) {
  219. for (p = 0; p < lmo.length; p++) {
  220. bazhuST += "@" + lmo[p] + "&nbsp;";
  221. }
  222. }
  223. (which_ed == "atta") ? unsafeWindow.test_editor.execCommand("inserthtml", bazhuST) : unsafeWindow.LzlEditor._s_p._se.execCommand("inserthtml", bazhuST);
  224. closeAttable();
  225. }
  226. //列表创建函数
  227. function creaseTable(UrlLength) {
  228. var tablepp = document.createElement("table");
  229. tablepp.id = "ATTAtablepp";
  230. var trs = [];
  231. for (ly = 0; ly <= Math.ceil(UrlLength / 3); ly++) {
  232. var tr = document.createElement("tr");
  233. mmd = trs.push(tr);
  234. tablepp.appendChild(tr);
  235. }
  236. for (ls = 0; ls < trs.length * 3; ls++) {
  237. var td = document.createElement("td");
  238. td.className = "ATeditFaceTxtTb";
  239. td.innerHTML = "<input type='text' class='inputInTd' value=''>";
  240. wq = Tds.push(td);
  241. trs[Math.floor(ls / 3)].appendChild(td);
  242. }
  243. return tablepp
  244. }
  245. //函数 编辑我的本吧吧友名单
  246. function promptMyfriend(el) {
  247. if (!document.getElementById("ATTAnewEditDiv")) {
  248. kpp = el.target.getAttribute("eclass");
  249. if (kpp == "promptMyfriend") {
  250. var ujuy = JSON.parse((localStorage["myBaFriends"]) ? localStorage["myBaFriends"] : "{}");
  251. var myfris = ujuy[thisPageTitle] ? ujuy[thisPageTitle] : [];
  252. } else {
  253. var myfris = ((localStorage["publicFriends"]) ? localStorage["publicFriends"] : "").split(",");
  254. }
  255. var ATTAnewEditDiv = document.createElement("div");
  256. ATTAnewEditDiv.id = "ATTAnewEditDiv";
  257.  
  258. var pageTitle = document.createElement("div");
  259. pageTitle.className = "pageTitle";
  260. pageTitle.innerHTML = "可直接修改或添加:";
  261. ATTAnewEditDiv.appendChild(pageTitle);
  262.  
  263. newTable = creaseTable(myfris.length);
  264. ATTAnewEditDiv.appendChild(newTable);
  265.  
  266. var yesButton = document.createElement("input");
  267. yesButton.type = "button";
  268. yesButton.className = "FTbutton";
  269. yesButton.value = "确定";
  270. yesButton.addEventListener("click", function () {
  271. var reGetArray = [];
  272. var hht = document.getElementsByClassName("inputInTd");
  273. for (hh = 0; hh < hht.length; hh++) {
  274. if (hht[hh].value != "") {
  275. ko = reGetArray.push(hht[hh].value.trim());
  276. }
  277. }
  278. if (reGetArray.length > 0) {
  279. if (kpp == "promptMyfriend") {
  280. ujuy[thisPageTitle] = reGetArray;
  281. } else {
  282. localStorage["publicFriends"] = reGetArray.toString();
  283. GM_setValue("publicFriends", reGetArray.toString());
  284. }
  285. } else {
  286. if (kpp == "promptMyfriend") {
  287. delete ujuy[thisPageTitle];
  288. } else {
  289. localStorage.removeItem("publicFriends");
  290. GM_deleteValue("publicFriends");
  291. }
  292. }
  293. if (kpp == "promptMyfriend") {
  294. localStorage["myBaFriends"] = JSON.stringify(ujuy);
  295. GM_setValue("myBaFriends", JSON.stringify(ujuy));
  296. loadThe("myBaFriends");
  297. } else {
  298. loadThe("publicFriends");
  299. }
  300. $(".inputInTd").html("");
  301. $("#ATTAtablepp").remove();
  302. $("#ATTAnewEditDiv").remove();
  303. }, false);
  304. ATTAnewEditDiv.appendChild(yesButton);
  305.  
  306. var addButton = document.createElement("input");
  307. addButton.type = "button";
  308. addButton.className = "FTbutton";
  309. addButton.value = "加行";
  310. addButton.addEventListener("click", function () {
  311. var tdNum = document.getElementsByClassName("inputInTd").length;
  312. var newTr = document.createElement("tr");
  313. document.getElementById("ATTAtablepp").appendChild(newTr);
  314. for (es = 0; es < 3; es++) {
  315. var newTD = document.createElement("td");
  316. newTD.className = "ATeditFaceTxtTb";
  317. newTD.innerHTML = "<input type='text' class='inputInTd' value=''>";
  318. newTr.appendChild(newTD);
  319. }
  320. }, false);
  321. ATTAnewEditDiv.appendChild(addButton);
  322. document.body.appendChild(ATTAnewEditDiv);
  323.  
  324. for (ss = 0; ss < myfris.length; ss++) {
  325. document.getElementsByClassName("inputInTd")[ss].value = myfris[ss];
  326. }
  327. }
  328. }
  329. //函数 绝对定位
  330. function getElementLeft(element) {
  331. var actualLeft = element.offsetLeft;
  332. var current = element.offsetParent;
  333. while (current !== null) {
  334. actualLeft += current.offsetLeft;
  335. current = current.offsetParent;
  336. }
  337. return actualLeft;
  338. }
  339. //函数 绝对定位
  340. function getElementTop(element) {
  341. var actualTop = element.offsetTop;
  342. var current = element.offsetParent;
  343. while (current !== null) {
  344. actualTop += current.offsetTop;
  345. current = current.offsetParent;
  346. }
  347. return actualTop;
  348. }
  349. //主函数 由编辑窗上方的@@@调用,展开主列表
  350. function createAttable(ete) {
  351. if (!document.getElementById("attaDiv")) {
  352. var ortt = ete.target;
  353. localStorage.which_editor = (ortt.id == "atta") ? 'atta' : 'atta_lzl';
  354. var getTop = (ortt.id == "atta") ? getElementTop(ortt) + 32 : getElementTop(ortt) + 20;
  355. //定位主列表位置
  356. if ($('#tb_rich_poster').css('position')=='fixed' && ortt.id == "atta") { //原子的悬浮窗
  357. GM_log("Mmax is here")
  358. var attaDiv = $("<div>", {
  359. id : "attaDiv"
  360. }).css({
  361. "position" : "fixed",
  362. "z-index" : "1000",
  363. "right" : "38px",
  364. "bottom" : "0"
  365. }).appendTo(document.body);
  366. } else if (ortt.id == "atta_lzl") { //楼中楼回复
  367. var attaDiv = $("<div>", {
  368. id : "attaDiv"
  369. }).css({
  370. "position" : "absolute",
  371. "z-index" : "1000",
  372. "left" : getElementLeft(ortt) - 200,
  373. "top" : getTop - 120
  374. }).appendTo(document.body);
  375. } else { //主窗
  376. var attaDiv = $("<div>", {
  377. id : "attaDiv"
  378. }).css({
  379. "position" : "absolute",
  380. "z-index" : "1000",
  381. "left" : getElementLeft(ortt) - 200,
  382. "top" : getTop
  383. }).appendTo(document.body);
  384. }
  385. //建表
  386. var atTable = $("<table>", {
  387. "border" : "1",
  388. "bordercolor" : "#B8B3FF",
  389. "cellpadding" : "6"
  390. }).appendTo(attaDiv);
  391. //TR
  392. var attr1 = $("<tr>").appendTo(atTable);
  393. var attr4 = $("<tr>").appendTo(atTable);
  394. var attr2 = $("<tr>").appendTo(atTable);
  395. var attr3 = $("<tr>").appendTo(atTable);
  396.  
  397. //左TD
  398. var td11 = $("<td>").appendTo(attr1);
  399. $("<div>", {
  400. html : "伟大吧主",
  401. class : "leftDiv"
  402. }).appendTo(td11);
  403. var td41 = $("<td>").appendTo(attr4);
  404. $("<div>", {
  405. html : "各位小吧",
  406. class : "leftDiv"
  407. }).appendTo(td41);
  408. var td21 = $("<td>", {
  409. "eclass" : "promptMyfriend",
  410. click : promptMyfriend
  411. }).appendTo(attr2);
  412. $("<div>", {
  413. "eclass" : "promptMyfriend",
  414. html : "本吧吧友",
  415. class : "leftDiv",
  416. title : "点击这里,可编辑本吧吧友名单"
  417. }).appendTo(td21);
  418. var td31 = $("<td>", {
  419. "eclass" : "promptPubfriend",
  420. click : promptMyfriend
  421. }).appendTo(attr3);
  422. $("<div>", {
  423. "eclass" : "promptPubfriend",
  424. html : "通用吧友",
  425. class : "leftDiv",
  426. title : "点击这里,可编辑通用吧友名单"
  427. }).appendTo(td31);
  428.  
  429. //右TD
  430. var td12 = $("<td>").appendTo(attr1);
  431. $("<div>", {
  432. id : "td12div",
  433. class : "rightDiv",
  434. dblclick : insertAll
  435. }).appendTo(td12);
  436. var td42 = $("<td>").appendTo(attr4);
  437. $("<div>", {
  438. id : "td42div",
  439. class : "rightDiv",
  440. dblclick : insertAll
  441. }).appendTo(td42);
  442. var td22 = $("<td>").appendTo(attr2);
  443. $("<div>", {
  444. id : "td22div",
  445. class : "rightDiv",
  446. dblclick : insertAll
  447. }).appendTo(td22);
  448. var td32 = $("<td>").appendTo(attr3);
  449. $("<div>", {
  450. id : "td32div",
  451. class : "rightDiv",
  452. dblclick : insertAll
  453. }).appendTo(td32);
  454.  
  455. //关闭按钮
  456. var closeDivbt = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA8UlEQVR42pWSMQrCQBBFcwPvI3gNKwtvYGVhaStqJYiFjY0IFmIrWEXRFIISiIqohYUYFcTC1gc/BFkSEmGyzMz/f3ZmNlaxMSvU7JQG2eJzdvdEW3j++vgstZ1AsNz6OgHkG6EpCFPe5S2qjHBzfgGZAuLV4TGw952Rg6MMVEKSZEyB7V6BW8NlJlcu1ccUPt0+1e6UkBMIgtkSKUi9iStSsz/H4SQJFD00ALXRZPMV2FxISDJ2S2qMpiVggFhB2BJsjaEB0ES3FO4k7dAqQHmm/F0rISMBRWxJjFQPF8IC9DsYoV42EOAlGtdyWyD4y76WWDtXsJol3gAAAABJRU5ErkJggg==";
  457. $("<span>", {
  458. class : "closeDivbt",
  459. click : closeAttable,
  460. html : "<img src='" + closeDivbt + "' alt='X' />"
  461. }).appendTo("#td12div");
  462.  
  463. //载入吧主到列表中
  464. loadThe("bigBaToday");
  465. //载入小吧到列表中
  466. loadThe("smallBaToday");
  467. //载入我的吧友
  468. loadThe("myBaFriends");
  469. //载入通用吧友
  470. loadThe("publicFriends");
  471. }
  472. }
  473. //关闭@@@列表
  474. function closeAttable() {
  475. $(".insertAt").detach();
  476. $(".rightDiv").detach();
  477. $(".leftDiv").detach();
  478. $("#attaDiv").detach();
  479. }
  480.  
  481. //函数 加入到我的吧友
  482. function addTomyFriend(elk) {
  483. var iopo = elk.target;
  484. var Ta = iopo.getAttribute("value");
  485. var r = confirm("把 " + Ta + " 添加到我的吧友?");
  486. if (r == true) {
  487. var ujuyu = JSON.parse((localStorage["myBaFriends"]) ? localStorage["myBaFriends"] : "{}");
  488. if (thisBaArray("bigBaToday").indexOf(Ta) == -1 && thisBaArray("smallBaToday").indexOf(Ta) == -1 && thisBaArray("publicFriends").indexOf(Ta) == -1) {
  489. if (ujuyu[thisPageTitle]) {
  490. if (ujuyu[thisPageTitle].indexOf(Ta) == -1) {
  491. ioii = ujuyu[thisPageTitle].push(Ta);
  492. }
  493. } else {
  494. ujuyu[thisPageTitle] = Ta.split(",");
  495. }
  496. localStorage["myBaFriends"] = JSON.stringify(ujuyu);
  497. setTimeout(function () {
  498. GM_setValue("myBaFriends", JSON.stringify(ujuyu));
  499. }, 0);
  500. } else {
  501. window.location = window.location.href;
  502. }
  503. temppp = "." + iopo.getAttribute("class") + "[value='" + Ta + "']";
  504. temppq = "." + iopo.getAttribute("class") + "[value='@" + Ta + "']";
  505. $(temppp + "," + temppq).each(function () {
  506. $(this).replaceWith($("<spam>", {
  507. title : "从我的@吧友中删除",
  508. value : Ta,
  509. html : "㈠",
  510. class : iopo.getAttribute("class") + "Back",
  511. click : removeFriend
  512. }));
  513. });
  514. }
  515. }
  516. //函数 从我的吧友中删除
  517. function removeFriend(bad) {
  518. var iopo = bad.target;
  519. var Ta = iopo.getAttribute("value");
  520. var r = confirm("把 " + Ta + " 从我的吧友中删除?");
  521. if (r == true) {
  522. var ujuyu = JSON.parse((localStorage["myBaFriends"]) ? localStorage["myBaFriends"] : "{}");
  523. var BaList = ujuyu[thisPageTitle] ? ujuyu[thisPageTitle].toString() : ""; //此判断仅用于A页已执行过删除,B页中尚未知觉的情况
  524. if (BaList != "") {
  525. if (BaList == Ta) {
  526. delete ujuyu[thisPageTitle];
  527. } else {
  528. BaList = BaList.replace(Ta + ',', '').replace(',' + Ta, '');
  529. ujuyu[thisPageTitle] = BaList.split(",");
  530. }
  531. }
  532. localStorage["myBaFriends"] = JSON.stringify(ujuyu);
  533. setTimeout(function () {
  534. GM_setValue("myBaFriends", JSON.stringify(ujuyu));
  535. }, 0);
  536. temppp = "." + iopo.getAttribute("class") + "[value='" + Ta + "']";
  537. temppq = "." + iopo.getAttribute("class") + "[value='@" + Ta + "']";
  538. $(temppp + "," + temppq).each(function () {
  539. $(this).replaceWith($("<spam>", {
  540. title : "添加到我的@吧友",
  541. value : Ta,
  542. html : "㈩",
  543. class : iopo.getAttribute("class").replace("Back", ""),
  544. click : addTomyFriend
  545. }));
  546. });
  547. }
  548. }
  549. //直接@它
  550. function justAtta(T) {
  551. var iopo = T.target;
  552. var Ta = iopo.innerHTML.replace("@", "");
  553. temp = '&nbsp;<span class="at">@' + Ta + '</span>&nbsp;';
  554. if (document.getElementById("Mark1") || document.getElementById("cMark")) { //兼容小脸
  555. smallFaceEnbale();
  556. }
  557. if (document.querySelector("#OaCbutton") && document.querySelector("#OaCbutton").getAttribute("status") == "close") {
  558. document.querySelector("#OaCbutton").click();
  559. }
  560. unsafeWindow.test_editor.execCommand("inserthtml", temp);
  561. }
  562. //大吧小吧来召唤
  563. function bbsbCall(ba) {
  564. var iopo = ba.target;
  565. var Ta = iopo.getAttribute("value");
  566. temp = '&nbsp;<span class="at">@' + Ta + '</span>&nbsp;';
  567. if (document.getElementById("Mark1") || document.getElementById("cMark")) { //兼容小脸
  568. smallFaceEnbale();
  569. }
  570. if (document.querySelector("#OaCbutton") && document.querySelector("#OaCbutton").getAttribute("status") == "close") {
  571. document.querySelector("#OaCbutton").click();
  572. }
  573. unsafeWindow.test_editor.execCommand("inserthtml", temp);
  574. }
  575.  
  576. //兼容小脸
  577. function smallFaceEnbale() {
  578. $('#cLinkContent1').css({
  579. "display" : 'table-cell'
  580. }); //兼容旧版小脸,打开编辑窗
  581. $('#cLinkContent').css({
  582. "display" : 'table-cell'
  583. }); //兼容新版小脸,打开编辑窗
  584. $('#menuSwitch').html('>>'); //兼容小脸,打开编辑窗
  585. }
  586.  
  587. /***************************华丽的分割线,以上为函数,以下为运行程序********************************/
  588.  
  589. //帖子内启动其功能函数
  590. if (window.location.href.indexOf("/p/") != -1 || window.location.href.indexOf("ct=") != -1 || window.location.href.indexOf("kz=") != -1) {
  591. //各ID加+
  592. addNodeInsertedListener('.p_author_name,a.at', function () {
  593. var Lhtml = this.innerHTML.replace("@", "");
  594. if (thisBaArray("bigBaToday").indexOf(Lhtml) != -1) {
  595. var ttitle = "这是大吧,可围观不可酱油,轻易别@它";
  596. var hhtml = "⑨";
  597. var cclass = "bbaaTabB";
  598. var cclick = bbsbCall;
  599. } else if (thisBaArray("smallBaToday").indexOf(Lhtml) != -1) {
  600. var ttitle = "这是小吧,想@就@吧~~";
  601. var hhtml = "②";
  602. var cclass = "bbaaTab";
  603. var cclick = bbsbCall;
  604. } else if (thisBaArray("publicFriends").indexOf(Lhtml) != -1) {
  605. var ttitle = "这是通用吧友,就是用来@的~~";
  606. var hhtml = "@";
  607. var cclass = "picFrdTab";
  608. var cclick = bbsbCall;
  609. } else if (thisBaArray("myBaFriends").indexOf(Lhtml) != -1) {
  610. var ttitle = "从我的@吧友中删除";
  611. var hhtml = "㈠";
  612. var cclass = "addPlusTabBack";
  613. var cclick = removeFriend;
  614. } else {
  615. var ttitle = "添加到我的@吧友";
  616. var hhtml = "㈩";
  617. var cclass = "addPlusTab";
  618. var cclick = addTomyFriend;
  619. }
  620. if ($(this).siblings("spam[value='" + Lhtml + "']").length == 0) {
  621. $("<spam>", {
  622. title : ttitle,
  623. html : hhtml,
  624. value : Lhtml,
  625. class : cclass,
  626. click : cclick
  627. }).insertAfter(this);
  628. }
  629. //帖子内点击直接@它 删除下面4行即可去掉这一功能,要想彻底删干净,就把函数justAtta也删掉
  630. this.title += " 点击直接@它";
  631. this.href = "javascript:void(0);";
  632. this.removeAttribute("target");
  633. this.removeAttribute("onmouseover");
  634. this.removeAttribute("onmouseout");
  635. this.addEventListener("click", justAtta, false);
  636. });
  637. //楼中楼加@@@
  638. addNodeInsertedListener('.lzl_panel_wrapper>tbody>tr>td:first-child', function () {
  639. if (!document.getElementById("atta_lzl")) {
  640. $("<em>", {
  641. id : "atta_lzl",
  642. html : "@@@",
  643. click : createAttable
  644. }).appendTo(this);
  645. }
  646. });
  647. }
  648.  
  649. //主编辑器添加@@@
  650. addNodeInsertedListener('.edui-btn-toolbar', function () {
  651. if (!document.getElementById("atta")) {
  652. $("<div>", {
  653. id : "atta",
  654. html : "@@@",
  655. click : createAttable
  656. }).appendTo(this);
  657. }
  658. })
  659.  
  660.  
  661. //主题列表
  662. if (window.location.href.indexOf("kw=") != -1) {
  663. //最后一页
  664. addNodeInsertedListener('#thread_list_table tr>td:nth-child(2),.threadlist_rep_num', function () {
  665. if (this.nodeName == "DIV") { //新版
  666. var getThisUrl = $(this.parentNode.parentNode).find("a").attr("href");
  667. } else { //旧版
  668. var getThisUrl = $(this.parentNode).find("a").attr("href");
  669. }
  670. var klii = this.innerHTML;
  671. if (klii > 30) {
  672. this.innerHTML = "";
  673. $("<a>", {
  674. href : "javascript:void(0);",
  675. title : "直达最后一页",
  676. html : klii
  677. }).click(function () {
  678. var jih = getThisUrl.split("/p/")[1];
  679. setTimeout(function () {
  680. GM_xmlhttpRequest({
  681. method : 'GET',
  682. url : "http://wapp.baidu.com/mo/m?kz=" + jih,
  683. headers : { //添加http头信息,希望有用
  684. 'Accept' : 'application/xhtml+xml'
  685. },
  686. onload : function (data) {
  687. var pn = $(data.responseText).find('[name="pnum"]').attr('value');
  688. if (pn == undefined) {
  689. var lastRes = data.responseText.match(/<a[ ]href[^>]+?pid=\d+/g);
  690. var lastRe = lastRes[lastRes.length - 1].replace(/<a[ ]href[^>]+?pid=/, "");
  691. window.location = 'http://tieba.baidu.com/p/' + jih + "?pid=" + lastRe + "#" + lastRe;
  692. } else {
  693. var lastUrl = data.responseText.match(/<\/a>&#160;<a[ ]href=".*last=1.*?(?=">)/)[0].replace('</a>&#160;<a href="', "").replace(/&amp;/g, "&");
  694. GM_xmlhttpRequest({
  695. method : 'GET',
  696. url : lastUrl,
  697. headers : {
  698. 'Accept' : 'application/xhtml+xml'
  699. },
  700. onload : function (yue) {
  701. var lastRe = yue.responseText.match(/flr\?pid=\d+(?=&)/)[0].replace('flr?pid=', '');
  702. window.location = 'http://tieba.baidu.com/p/' + jih + "?pid=" + lastRe + "#" + lastRe;
  703. }
  704. })
  705. }
  706. }
  707. });
  708. }, 0);
  709. }).appendTo(this);
  710. }
  711. });
  712.  
  713. //今天的日期和本吧名
  714. var yuy = new Date();
  715. var fulltime = yuy.toLocaleDateString();
  716.  
  717. //收集每日各贴吧版主信息
  718. var bigBaToday = JSON.parse((localStorage["bigBaToday"]) ? localStorage["bigBaToday"] : "{}");
  719. if ($(".manager_btn").length > 0 && (bigBaToday.date != fulltime || !bigBaToday[thisPageTitle])) {
  720. GM_log(thisPageTitle + " " + fulltime + " " + "大吧主信息收集,每天只一次。");
  721. var Bazhus = [];
  722. var thisBaBazhu = $(".region_cnt>ul:first>li>a");
  723. for (t = 0; t < thisBaBazhu.length; t++) {
  724. qwqq = Bazhus.push(thisBaBazhu[t].innerHTML);
  725. }
  726. if (bigBaToday.date != fulltime) {
  727. bigBaToday = {};
  728. bigBaToday.date = fulltime;
  729. bigBaToday[thisPageTitle] = Bazhus;
  730. } else {
  731. bigBaToday[thisPageTitle] = Bazhus;
  732. }
  733. localStorage["bigBaToday"] = JSON.stringify(bigBaToday);
  734. }
  735. //收集各小吧信息
  736. var getSmallbas = JSON.parse((localStorage["smallBaToday"]) ? localStorage["smallBaToday"] : "{}");
  737. if ($(".manager_btn").length > 0 && (getSmallbas.date != fulltime || !getSmallbas[thisPageTitle])) {
  738. GM_log(thisPageTitle + " " + fulltime + " " + "小吧主信息收集,每天只一次。");
  739. var smallbaUrl = window.location.href.replace("f?", "f/bawu/admin_group?");
  740. GM_xmlhttpRequest({
  741. method : 'GET',
  742. synchronous : true,
  743. url : smallbaUrl,
  744. onload : function (reDetails) {
  745. var retxt1 = reDetails.responseText.replace(/\r/gi, "").replace(/\n/gi, "");
  746. var retxt2 = retxt1.replace(/.*小吧主:<\/td[ ]><td[ ]style="padding-bottom:20px;"[ ]>&nbsp;/, "").replace(/&nbsp;<\/td[ ]><\/tr[ ]><tr[ ]valign="top"[ ]><td[ ]width="70"[ ]align="right"[ ]>图片小编:.*/, "");
  747. var retxt = retxt2.match(/" >.*?</g);
  748. if (retxt.length > 0) {
  749. smallbar = "";
  750. for (w = 0; w < retxt.length; w++) {
  751. smallbar += ((smallbar == "") ? "" : ",") + retxt[w].replace(/[" ><]/g, "");
  752. }
  753. if (getSmallbas.date != fulltime) {
  754. getSmallbas = {};
  755. getSmallbas.date = fulltime;
  756. getSmallbas[thisPageTitle] = smallbar.split(",");
  757. } else {
  758. getSmallbas[thisPageTitle] = smallbar.split(",");
  759. }
  760. localStorage['smallBaToday'] = JSON.stringify(getSmallbas);
  761. }
  762. }
  763. })
  764. }
  765.  
  766. //各ID加+
  767. addNodeInsertedListener('tr>td:nth-child(4):not(.ffs_j_smile_text)>a:not(.img),tr>td:nth-child(5):not(.ffs_j_smile_text)>a:not(.img),.tb_icon_author>a:first-child,.tb_icon_author_rely>a', function () {
  768. if (this.parentNode.title) {
  769. Lhtml = this.parentNode.title.match(/.*[::]\s?(.*)/)[1];
  770. } else if (this.parentNode.parentNode.title) {
  771. Lhtml = this.parentNode.parentNode.title.match(/.*[::]\s?(.*)/)[1];
  772. }
  773. this.innerHTML = Lhtml.reComLength();
  774. if (thisBaArray("bigBaToday").indexOf(Lhtml) != -1) {
  775. var ttitle = "这是大吧,可围观不可酱油,轻易别@它";
  776. var hhtml = "⑨";
  777. var cclass = "bbaaB";
  778. var cclick = bbsbCall;
  779. } else if (thisBaArray("smallBaToday").indexOf(Lhtml) != -1) {
  780. var ttitle = "这是小吧,想@就@吧~~";
  781. var hhtml = "②";
  782. var cclass = "bbaa";
  783. var cclick = bbsbCall;
  784. } else if (thisBaArray("publicFriends").indexOf(Lhtml) != -1) {
  785. var ttitle = "这是通用吧友,就是用来@的~~";
  786. var hhtml = "@";
  787. var cclass = "picFrd";
  788. var cclick = bbsbCall;
  789. } else if (thisBaArray("myBaFriends").indexOf(Lhtml) != -1) {
  790. var ttitle = "从我的@吧友中删除";
  791. var hhtml = "㈠";
  792. var cclass = "addPlusBack";
  793. var cclick = removeFriend;
  794. } else {
  795. var ttitle = "添加到我的@吧友";
  796. var hhtml = "㈩";
  797. var cclass = "addPlus";
  798. var cclick = addTomyFriend;
  799. }
  800. if ($(this).siblings("spam").length == 0) {
  801. $("<spam>", {
  802. title : ttitle,
  803. html : hhtml,
  804. value : Lhtml,
  805. class : cclass,
  806. click : cclick
  807. }).insertBefore(this);
  808. }
  809. });
  810. }
  811.  
  812. //上传图片默认不选中“加本吧水印”的复选框
  813. addNodeInsertedListener('.i_checkbox', function () {
  814. this.checked = false;
  815. });

QingJ © 2025

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