tieba_At_Ta

百度贴吧@它

当前为 2014-05-28 提交的版本,查看 最新版本

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

QingJ © 2025

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