tieba_At_Ta

百度贴吧@它

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