tieba_faceText

百度贴吧颜文字

  1. // ==UserScript==
  2. // @name tieba_faceText
  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/daquan*
  13. // @exclude http://tieba.baidu.com/f/tupian*
  14. // @exclude http://tieba.baidu.com/tb/*
  15. // @exclude http://tieba.baidu.com/*postBrowserBakan*
  16. // @icon http://tb.himg.baidu.com/sys/portraitn/item/4e2ed7f8bbb3d4f2c2d2bb21
  17. // @require http://libs.baidu.com/jquery/2.0.0/jquery.min.js
  18. // @author congxz6688
  19. // @version 2017.2.28.0
  20. // @grant GM_getValue
  21. // @grant GM_setValue
  22. // @grant GM_deleteValue
  23. // @namespace https://gf.qytechs.cn/scripts/150
  24. // ==/UserScript==
  25.  
  26.  
  27. //初始颜文字表情
  28. var defaultFaceText = {
  29. "faceText0" : ["(>_<)", "o(>< )o", "o( ><)o", "(>д<)", "ヽ(#`Д´)ノ", "ヽ(≧Д≦)ノ", ">﹏<", "┌( ಠ_ಠ)┘"],
  30. "faceText1" : ["( ̄︿ ̄)", "(¬д¬。)", "(¬、¬)", "(;¬_¬)", "(;¬_¬)", "(;¬д¬)", "( ;´Д`)", "o( ̄ヘ ̄o#)"],
  31. "faceText2" : ["T_T", "(T_T)", "( TДT)", "(ToT)", "(T▽T)", "(T_T)", "(;へ:)", "(ノД`)・゜・。", "(´_`。)", "(´A`。)", "(´∩`。)", "。・゚゚・(>д<;)・゚゚・。", "(*´;ェ;`*)", "(个_个)", ",,Ծ‸Ծ,,", "〒▽〒"],
  32. "faceText3" : ["(*゚∇゚)", "(*´∀`)", "( ゚∀゚)", "o(ノ゚∀゚)ノ", "( ̄∇ ̄)", "o(*≥▽≤)ツ", "(`・ω・´)", "(。◕∀◕。)", "ノ( ◕‿‿◕ )ノ", "(๑→ܫ←)", "(@ ̄) ̄@)", "(●'‿'●)", "(✿✪‿✪。)ノ♡", "(O ^ ~ ^ O)"],
  33. "faceText4" : ["( ̄(エ) ̄)", "(^(エ)^)", "⊂(・(ェ)・)⊃", "(* ̄(エ) ̄*)", "(=^・ェ・^=)", "(=;ェ;=)", "ヽ(=^・ω・^=)丿", "<(*ΦωΦ*)>", "Uo・ェ・oU", "ヾ(●ω●)ノ", "U・♀・U", "U^ェ^U", "(´(ェ)‘)"],
  34. "faceText5" : ["(*・_・)ノ⌒ ⌒ ⌒╭*", "*★.°*:.☆( ̄▽ ̄)ノ:*.°★* 。", "╭∩╮( ̄︿ ̄)╭∩╮", "(╯`□′)╯~~╧╧", "((((*。_。)_", "⊂彡☆))д`)", "( ̄3 ̄)", "(|||゚д゚)", "( д ) ゚ ゚", "@_@", "-_-!!!", "(`ε´ )", "(→_→)", "(@[]@!!)"],
  35. "faceText6" : ["⊙﹏⊙‖∣°", "(—。—) . z Z", "d(*◕ ‿ -) :|} - - >>—>"],
  36. "faceText7" : ["段落演示"]
  37. };
  38. var EasyInsertTextDemo = {"段落演示" : "坐怀则乱是天然纯洁的,我们都要爱护他。"};
  39.  
  40.  
  41. function addStyle(css){
  42. document.head.appendChild(document.createElement("style")).textContent = css;
  43. }
  44.  
  45. //下面这一段CSS,可帮助编辑器工具栏不够用的同学,会CSS的同学可删除它。
  46. var forCss2er = ".cut_screen{display:none!important;}";
  47. forCss2er += ".tb-editor-wrapper{width:720px !important}";
  48. forCss2er += ".recentImgDiv>.tb-editor-overlay{left:28% !important; top:30px !important;}";
  49. addStyle(forCss2er);
  50.  
  51.  
  52.  
  53.  
  54. //脚本双存储相互恢复
  55. if (!localStorage.userFaceText && GM_getValue("userFaceText", "") != "") {
  56. localStorage.userFaceText = GM_getValue("userFaceText");
  57. }
  58. if (GM_getValue("userFaceText", "") == "" && localStorage.userFaceText) {
  59. GM_setValue("userFaceText", localStorage.userFaceText);
  60. }
  61.  
  62. if (!localStorage.EasyInsertText && GM_getValue("EasyInsertText", "") != "") {
  63. localStorage.EasyInsertText = GM_getValue("EasyInsertText");
  64. }
  65. if (GM_getValue("EasyInsertText", "") == "" && localStorage.EasyInsertText) {
  66. GM_setValue("EasyInsertText", localStorage.EasyInsertText);
  67. }
  68.  
  69. //脚本主CSS
  70. var replyCss = "";
  71. replyCss += ".insertFacetxt,.quickInsert{background-color: #E5E5E0; padding:0px 3px; margin:2px 6px; cursor:pointer; display:inline-block;}";
  72. replyCss += "#faceTextDiv{background-color:lightGrey; width:650px; border:4px double gray;}";
  73. replyCss += ".FTLeftDiv{cursor:pointer; display:inline-block; background-color:lightGrey;padding:3px 10px; width:36px;}";
  74. replyCss += ".FTRightDiv{display:inline-block; background-color:lightGrey; padding:3px 6px; width:579px;}";
  75. replyCss += ".closeFTDivbt{cursor:pointer; float:right; margin:0px -2px; width:16px; height:16px;}";
  76. replyCss += "#editorButton{cursor:pointer; margin:0 0 0 16px; display:inline-block; color:#3163B6; padding: 1px 1px 10px 1px; position:relative; top:0px}";
  77. replyCss += "#editorButton_lzl{margin:0 5px 3px 5px; float:right;cursor:pointer; font-size:1.2em; display:inline-block; color:#3163B6;}";
  78. replyCss += ".editFaceTxtTb{width:200px; padding:1px 1px 0 0;} .inputInTdFt{width:199px;} .FTbutton{float:right; padding:0px 10px; margin:15px 10px 0px 0px}";
  79. replyCss += "#defaultDiv{color: red; padding:0px 10px; margin:15px 0px 0px 159px}";
  80. replyCss += "#newEditDiv{border: 1px solid gray; width:612px; z-index:10002; background-color:#EEEEEE; padding:20px; position:fixed; left:200px; bottom:80px;} #newEditDiv *:not(.pageTitle),#faceTextDiv *{font-size:12px !important;}";
  81. replyCss += ".quickEditdiv{margin:1px; border: 1px solid gray; width:200px; display:inline-block;}"
  82. replyCss += ".qdisplayDiv{margin-left:3px; width:137px; display:inline-block;}"
  83. replyCss += ".modifyQuichText{padding-left:3px; background-color:#D0FFD0; cursor:pointer; width:27px; display:inline-block;}"
  84. replyCss += ".deleteQuichText{padding-left:3px; background-color:#FFD0D0; cursor:pointer; width:27px; display:inline-block;}";
  85. replyCss += "#fuuuffs{width:612px;} .margin-top30{padding-top:20px;} .editSbuttom{ display:inline-block; padding:0px 10px; margin-right:9px; margin-top:10px;}"
  86. replyCss += "#titleInput{width:136px;} #lotTextArea{width:454px} #inSertThenSubmit{position:relative; top:1px;} .checkboxDiv{float:right; margin:18px 50px 0px 0px}";
  87. addStyle(replyCss);
  88.  
  89. var Tds = []; //数据修改用列表
  90.  
  91.  
  92. //函数 数组字符串重排序
  93. Array.prototype.reIndex = function () {
  94. var lastStr = this.sort(function (a, b) {
  95. return a.localeCompare(b)
  96. });
  97. return lastStr;
  98. }
  99. //元素精确监听
  100. function addNodeInsertedListener(elCssPath, handler, executeOnce, noStyle) {
  101. var animName = "anilanim",
  102. prefixList = ["-o-", "-ms-", "-khtml-", "-moz-", "-webkit-", ""],
  103. eventTypeList = ["animationstart", "webkitAnimationStart", "MSAnimationStart", "oAnimationStart"],
  104. forEach = function (array, func) {
  105. for (var i = 0, l = array.length; i < l; i++) {
  106. func(array[i]);
  107. }
  108. };
  109. if (!noStyle) {
  110. var css = elCssPath + "{",
  111. css2 = "";
  112. forEach(prefixList, function (prefix) {
  113. css += prefix + "animation-duration:.001s;" + prefix + "animation-name:" + animName + ";";
  114. css2 += "@" + prefix + "keyframes " + animName + "{from{opacity:.9;}to{opacity:1;}}";
  115. });
  116. css += "}" + css2;
  117. addStyle(css);
  118. }
  119. if (handler) {
  120. var bindedFunc = function (e) {
  121. var els = document.querySelectorAll(elCssPath),
  122. tar = e.target,
  123. match = false;
  124. if (els.length !== 0) {
  125. forEach(els, function (el) {
  126. if (tar === el) {
  127. if (executeOnce) {
  128. removeNodeInsertedListener(bindedFunc);
  129. }
  130. handler.call(tar, e);
  131. return;
  132. }
  133. });
  134. }
  135. };
  136. forEach(eventTypeList, function (eventType) {
  137. document.addEventListener(eventType, bindedFunc, false);
  138. });
  139. return bindedFunc;
  140. }
  141. }
  142. //移除精确监听
  143. function removeNodeInsertedListener(bindedFunc) {
  144. var eventTypeList = ["animationstart", "webkitAnimationStart", "MSAnimationStart", "oAnimationStart"],
  145. forEach = function (array, func) {
  146. for (var i = 0, l = array.length; i < l; i++) {
  147. func(array[i]);
  148. }
  149. };
  150. forEach(eventTypeList, function (eventType) {
  151. document.removeEventListener(eventType, bindedFunc, false);
  152. });
  153. }
  154. //提取localStorage的参数
  155. function getLSJS(a){
  156. return JSON.parse(localStorage[a] ? localStorage[a] : "{}");
  157. }
  158. //简化脚本
  159. function crE(a){
  160. return document.createElement(a);
  161. }
  162. function getId(a){
  163. return document.getElementById(a);
  164. }
  165. //函数 载入各名单
  166. function loadThe(ff) {
  167. function ffe(ww) {
  168. $("#tdRightDiv" + ww + ">.insertFacetxt,#tdRightDiv" + ww + ">.quickInsert").remove();
  169. var searchSave = getLSJS("userFaceText");
  170. myFri = (searchSave["faceText" + ww]) ? searchSave["faceText" + ww] : defaultFaceText["faceText" + ww];
  171. if (ww == "7") {
  172. aqq = (localStorage.EasyInsertText) ? JSON.parse(localStorage.EasyInsertText) : EasyInsertTextDemo;
  173. myFri = myFri.reIndex();
  174. }
  175. var parentDiv = $("#tdRightDiv" + ww);
  176. if (myFri.length != 0) {
  177. for (l = 0; l < myFri.length; l++) {
  178. $("<span>", {
  179. html : myFri[l],
  180. title : ((ww == "7") ? ((aqq[myFri[l]].length < 30) ? aqq[myFri[l]] : aqq[myFri[l]].substr(0, 30) + "...") : undefined),
  181. class : ((ww == "7") ? "quickInsert" : "insertFacetxt"),
  182. click : insertEdiror
  183. }).appendTo(parentDiv);
  184. }
  185. }
  186. }
  187. if (ff == "all") {
  188. for (p = 0; p < 8; p++) {
  189. ffe("" + p);
  190. }
  191. } else {
  192. ffe(ff);
  193. }
  194. }
  195. //保存数据
  196. function saveData(a, b) {
  197. if ($.isEmptyObject(a)) {
  198. localStorage.removeItem(b);
  199. GM_deleteValue(b);
  200. } else {
  201. localStorage[b] = JSON.stringify(a);
  202. GM_setValue(b, JSON.stringify(a));
  203. }
  204. }
  205.  
  206. //函数 插入到编辑器
  207. function insertEdiror(e) {
  208. var whh = e.target.innerHTML;
  209. var insertKind = e.target.getAttribute("class");
  210. if (insertKind == "quickInsert") {
  211. var InsertText = ((localStorage.EasyInsertText) ? JSON.parse(localStorage.EasyInsertText) : EasyInsertTextDemo)[whh] + "&nbsp;";
  212. } else {
  213. var InsertText = whh + "&nbsp;";
  214. }
  215. var editor = (localStorage['FT_which_editor']) ? localStorage['FT_which_editor'] : 'editorButton';
  216. if (editor == "editorButton") {
  217. unsafeWindow.test_editor.execCommand("inserthtml", InsertText);
  218. setTimeout(function () {
  219. if (insertKind == "quickInsert" && window.location.href.indexOf("kw=") == -1 && GM_getValue('inSertThenSubmit', false)) {
  220. document.querySelector(".poster_submit").click();
  221. }
  222. }, 1000);
  223. } else if (InsertText.indexOf("<img") == -1 || InsertText.indexOf("http://static.tieba.baidu.com") != -1) {
  224. unsafeWindow.LzlEditor._s_p._se.execCommand("inserthtml", InsertText);
  225. setTimeout(function () {
  226. if (insertKind == "quickInsert" && window.location.href.indexOf("kw=") == -1 && GM_getValue('inSertThenSubmit', false)) {
  227. document.querySelector(".lzl_panel_btn>.lzl_panel_submit").click();
  228. }
  229. }, 500);
  230. }
  231. closeFaceTxttable();
  232. }
  233. //列表创建函数
  234. function creaseTable(UrlLength) {
  235. var tablepp = crE("table");
  236. tablepp.id = "tablepp";
  237. var trs = [];
  238. for (ly = 0; ly <= Math.ceil(UrlLength / 3); ly++) {
  239. var tr = crE("tr");
  240. mmd = trs.push(tr);
  241. tablepp.appendChild(tr);
  242. }
  243. for (ls = 0; ls < trs.length * 3; ls++) {
  244. var td = crE("td");
  245. td.className = "editFaceTxtTb";
  246. td.innerHTML = "<input type='text' class='inputInTdFt' value=''>";
  247. wq = Tds.push(td);
  248. trs[Math.floor(ls / 3)].appendChild(td);
  249. }
  250. return tablepp
  251. }
  252. //函数 编辑我的自定义颜文字
  253. function promptUserFT(ev) {
  254. if (!getId("newEditDiv")) {
  255. var wK = ev.target.id.split("tdLeftDiv")[1];
  256. var ujuy = getLSJS("userFaceText");
  257. var faceText = (ujuy["faceText" + wK]) ? ujuy["faceText" + wK] : defaultFaceText["faceText" + wK];
  258.  
  259. var newEditDiv = crE("div");
  260. newEditDiv.id = "newEditDiv";
  261.  
  262. $("<div>", {
  263. class : "pageTitle",
  264. html : "可直接修改表格内容或添加新表情到表格中:"
  265. }).css({
  266. "font-size" : "16px",
  267. "margin-bottom" : "15px"
  268. }).appendTo(newEditDiv);
  269.  
  270. newTable = creaseTable(faceText.length);
  271. newEditDiv.appendChild(newTable);
  272.  
  273. var yesButton = crE("input");
  274. yesButton.type = "button";
  275. yesButton.className = "FTbutton";
  276. yesButton.value = "确定";
  277. yesButton.addEventListener("click", function () {
  278. var reGetArray = [];
  279. var hht = document.getElementsByClassName("inputInTdFt");
  280. for (hh = 0; hh < hht.length; hh++) {
  281. if (hht[hh].value != "") {
  282. ko = reGetArray.push(hht[hh].value.trim());
  283. }
  284. }
  285. if (reGetArray.length > 0) {
  286. if (reGetArray.toString() != faceText.toString()) {
  287. ujuy["faceText" + wK] = reGetArray;
  288. }
  289. } else {
  290. delete ujuy["faceText" + wK];
  291. }
  292. saveData(ujuy, "userFaceText")
  293. loadThe(wK);
  294.  
  295. $(".inputInTdFt").html("");
  296. $("#tablepp").detach();
  297. $("#newEditDiv").detach();
  298. }, false);
  299. newEditDiv.appendChild(yesButton);
  300.  
  301. var addButton = crE("input");
  302. addButton.type = "button";
  303. addButton.className = "FTbutton";
  304. addButton.value = "加行";
  305. addButton.addEventListener("click", function () {
  306. var tdNum = document.getElementsByClassName("inputInTdFt").length;
  307. var newTr = crE("tr");
  308. getId("tablepp").appendChild(newTr);
  309. for (es = 0; es < 3; es++) {
  310. var newTD = crE("td");
  311. newTD.className = "editFaceTxtTb";
  312. newTD.innerHTML = "<input type='text' class='inputInTdFt' value=''>";
  313. newTr.appendChild(newTD);
  314. }
  315. }, false);
  316. newEditDiv.appendChild(addButton);
  317.  
  318. if (ujuy["faceText" + wK]) {
  319. var addButton = crE("input");
  320. addButton.type = "button";
  321. addButton.className = "FTbutton";
  322. addButton.value = "恢复本类默认";
  323. addButton.addEventListener("click", function () {
  324. var alertMe = confirm("这一动作将删除本类表情的修改和添加,\r\n你确定要这么做吗?");
  325. if (alertMe) {
  326. delete ujuy["faceText" + wK];
  327. saveData(ujuy, "userFaceText");
  328. loadThe(wK);
  329. $(".inputInTdFt").html("");
  330. $("#tablepp").detach();
  331. $("#newEditDiv").detach();
  332. }
  333. }, false);
  334. newEditDiv.appendChild(addButton);
  335. }
  336.  
  337. document.body.appendChild(newEditDiv);
  338.  
  339. for (ss = 0; ss < faceText.length; ss++) {
  340. document.getElementsByClassName("inputInTdFt")[ss].value = faceText[ss];
  341. }
  342. }
  343. }
  344. //函数 编辑我的快速输入文字
  345. function promptEasyInsert() {
  346. if (!getId("newEditDiv")) {
  347. var newEditDiv = crE("div");
  348. newEditDiv.id = "newEditDiv";
  349. document.body.appendChild(newEditDiv);
  350.  
  351. $("<div>", {
  352. html : "段落快速输入功能的设置页",
  353. class : "pageTitle"
  354. }).css({
  355. "font-size" : "16px",
  356. "margin-bottom" : "15px"
  357. }).appendTo(newEditDiv);
  358.  
  359. var tablepp = crE("table");
  360. var tr1 = crE("tr");
  361. var td1 = crE("td");
  362. td1.setAttribute("colspan", "2");
  363. var ffdiv = crE("div");
  364. ffdiv.id = "fuuuffs";
  365. td1.appendChild(ffdiv);
  366. tr1.appendChild(td1);
  367.  
  368. var tr3 = crE("tr");
  369. var td6 = crE("td");
  370. td6.className = "margin-top30";
  371. td6.innerHTML = "这里输入段落名称:";
  372. var td7 = crE("td");
  373. td7.className = "margin-top30";
  374. td7.innerHTML = "这里输入段落内容:";
  375. tr3.appendChild(td6);
  376. tr3.appendChild(td7);
  377.  
  378. var tr2 = crE("tr");
  379. var td2 = crE("td");
  380.  
  381. var inputTit = crE("input");
  382. inputTit.type = "text";
  383. inputTit.id = "titleInput";
  384. inputTit.value = "";
  385. td2.appendChild(inputTit);
  386.  
  387. var saveButton = crE("input");
  388. saveButton.className = "editSbuttom";
  389. saveButton.type = "button";
  390. saveButton.value = "保 存";
  391. saveButton.addEventListener("click", function () {
  392. var titValue = getId("titleInput").value;
  393. var innText = getId("lotTextArea").value.replace(/\n/g, "<br>");
  394. if (innText.indexOf('<img') == -1) {
  395. //自动识别图片并加标签http://imgsrc.baidu.com/forum/pic/item/
  396. innText = innText.replace(/(http:\/\/(?!static\.tieba).*?)([0-9a-z]{40})(\.jpg|\.png|\.gif)/i, '<img class="BDE_Image" unselectable="on" onload="EditorUI.resizeImage(this, 560)" pic_type="1" src="' + 'http://imgsrc.baidu.com/forum/pic/item/' + '$2$3">');
  397. //自动识别表情并加标签
  398. innText = innText.replace(/(http:\/\/static\.tieba\.baidu\.com.*?)(\.jpg|\.png|\.gif)/i, '<img class="BDE_Smiley" unselectable="on" onload="EditorUI.resizeImage(this, 560)" pic_type="1" src="$1$2">');
  399. }
  400. if (titValue != "" && innText != "") {
  401. var userFacee = getLSJS("userFaceText");
  402. var temmm = (userFacee.faceText7) ? userFacee.faceText7 : [];
  403. if (temmm.indexOf(titValue) != -1) {
  404. var coverAlert = confirm("已经有了一个同名的段落,要覆盖吗?");
  405. if (coverAlert) {
  406. var temss = getLSJS("EasyInsertText");
  407. temss[titValue] = innText;
  408. localStorage.EasyInsertText = JSON.stringify(temss);
  409. GM_setValue("EasyInsertText", JSON.stringify(temss));
  410.  
  411. getId("titleInput").value = "";
  412. getId("lotTextArea").value = "";
  413. EditQuickLoad();
  414. }
  415. } else {
  416. sdd = temmm.push(titValue);
  417. userFacee.faceText7 = temmm;
  418. localStorage.userFaceText = JSON.stringify(userFacee);
  419. GM_setValue("userFaceText", JSON.stringify(userFacee));
  420.  
  421. var temss = getLSJS("EasyInsertText");
  422. temss[titValue] = innText;
  423. localStorage.EasyInsertText = JSON.stringify(temss);
  424. GM_setValue("EasyInsertText", JSON.stringify(temss));
  425.  
  426. getId("titleInput").value = "";
  427. getId("lotTextArea").value = "";
  428. EditQuickLoad();
  429. }
  430. } else {
  431. var message = (titValue == "") ? "段落名称" : "段落内容";
  432. alert(message + "不能为空!请填好再按保存。");
  433. }
  434. }, false);
  435. td2.appendChild(saveButton);
  436.  
  437. var clearButton = crE("input");
  438. clearButton.className = "editSbuttom";
  439. clearButton.type = "button";
  440. clearButton.value = "清 除";
  441. clearButton.addEventListener("click", function () {
  442. getId("titleInput").value = "";
  443. getId("lotTextArea").value = "";
  444. }, false);
  445. td2.appendChild(clearButton);
  446.  
  447. var td3 = crE("td");
  448. var inTextArea = crE("textarea");
  449. inTextArea.id = "lotTextArea";
  450. inTextArea.rows = "3";
  451. td3.appendChild(inTextArea);
  452.  
  453. tr2.appendChild(td2);
  454. tr2.appendChild(td3);
  455. tablepp.appendChild(tr1);
  456. tablepp.appendChild(tr3);
  457. tablepp.appendChild(tr2);
  458. newEditDiv.appendChild(tablepp);
  459.  
  460. function EditQuickLoad() {
  461. $(".quickEditdiv").remove();
  462. var ujuy = getLSJS("userFaceText");
  463. var faceText = (ujuy["faceText7"]) ? ujuy["faceText7"] : defaultFaceText["faceText7"];
  464. faceText = faceText.reIndex();
  465. for (ls = 0; ls < faceText.length; ls++) {
  466. var inlineBlock = crE("div");
  467. inlineBlock.className = "quickEditdiv";
  468.  
  469. var newspan = crE("span");
  470. newspan.innerHTML = faceText[ls];
  471. newspan.className = "qdisplayDiv";
  472. inlineBlock.appendChild(newspan);
  473.  
  474. var modifyBu = crE("span");
  475. modifyBu.className = "modifyQuichText";
  476. modifyBu.setAttribute("qval", faceText[ls]);
  477. modifyBu.title = "点击以后到下面修改";
  478. modifyBu.innerHTML = "修改";
  479. modifyBu.addEventListener("click", modifyQuickText, false);
  480. inlineBlock.appendChild(modifyBu);
  481.  
  482. var deleteBu = crE("span");
  483. deleteBu.className = "deleteQuichText";
  484. deleteBu.setAttribute("qval", faceText[ls]);
  485. deleteBu.title = "删除这一条";
  486. deleteBu.innerHTML = "删除";
  487. deleteBu.addEventListener("click", deleteQuickText, false);
  488. inlineBlock.appendChild(deleteBu);
  489.  
  490. ffdiv.appendChild(inlineBlock);
  491. }
  492. }
  493. function modifyQuickText(ee) {
  494. var yaa = ee.target.getAttribute("qval");
  495. getId("titleInput").value = yaa;
  496. getId("lotTextArea").value =((localStorage.EasyInsertText) ? JSON.parse(localStorage.EasyInsertText) : EasyInsertTextDemo)[yaa];
  497. }
  498. function deleteQuickText(ee) {
  499. var yaa = ee.target.getAttribute("qval");
  500. var deleteAlert = confirm("删除段落: " + yaa + "\r\n\r\n你确定吗?");
  501. if (deleteAlert) {
  502. var userFace = getLSJS("userFaceText");
  503. var temm = (userFace.faceText7) ? userFace.faceText7.toString().replace("," + yaa, "").replace(yaa + ",", "").replace(yaa, "") : "";
  504. if (temm == "") {
  505. delete userFace.faceText7;
  506. } else {
  507. userFace.faceText7 = temm.split(",");
  508. }
  509. saveData(userFace, "userFaceText");
  510. var tema = getLSJS("EasyInsertText");
  511. delete tema[yaa];
  512. saveData(tema, "EasyInsertText");
  513. EditQuickLoad();
  514. }
  515. }
  516. EditQuickLoad();
  517.  
  518. //确定按钮
  519. var yesButton = crE("input");
  520. yesButton.type = "button";
  521. yesButton.className = "FTbutton";
  522. yesButton.value = "关 闭 本 页";
  523. yesButton.addEventListener("click", function () {
  524. loadThe("7");
  525. document.body.removeChild(getId("newEditDiv"));
  526. }, false);
  527. newEditDiv.appendChild(yesButton);
  528.  
  529. //福利
  530. var smallDiv = crE("div");
  531. smallDiv.className = "checkboxDiv";
  532. var inSertThenSubmit = crE("input");
  533. inSertThenSubmit.type = "checkbox";
  534. inSertThenSubmit.id = "inSertThenSubmit";
  535. inSertThenSubmit.checked = GM_getValue('inSertThenSubmit', false);
  536. inSertThenSubmit.addEventListener('click', function () {
  537. GM_setValue('inSertThenSubmit', getId("inSertThenSubmit").checked);
  538. }, true);
  539. smallDiv.appendChild(inSertThenSubmit);
  540. var smallSpan = crE("span");
  541. smallSpan.innerHTML = " 插入后自动发表";
  542. smallDiv.appendChild(smallSpan);
  543. newEditDiv.appendChild(smallDiv);
  544.  
  545. //全部恢复默认
  546. var defaultDiv = crE("input");
  547. defaultDiv.type = "button";
  548. defaultDiv.title = "除非保存的数据出现无法恢复的异常,否则最好不要用这个!";
  549. defaultDiv.id = "defaultDiv";
  550. defaultDiv.value = "删 除 所 有 段 落";
  551. defaultDiv.addEventListener('click', function () {
  552. var deleteAlert = confirm("!!!把所有保存的段落全部删除!!!\r\n\r\n数据将无法恢复!你确定吗?");
  553. if (deleteAlert) {
  554. var defaultTemp = getLSJS("userFaceText");
  555. delete defaultTemp.faceText7;
  556. saveData(defaultTemp, "userFaceText");
  557. localStorage.removeItem("EasyInsertText");
  558. GM_deleteValue("EasyInsertText");
  559. EditQuickLoad();
  560. }
  561. }, true);
  562. newEditDiv.appendChild(defaultDiv);
  563. }
  564. }
  565. //函数 绝对定位
  566. function getElementLeft(element) {
  567. var actualLeft = element.offsetLeft;
  568. var current = element.offsetParent;
  569. while (current !== null) {
  570. actualLeft += current.offsetLeft;
  571. current = current.offsetParent;
  572. }
  573. return actualLeft;
  574. }
  575. //函数 绝对定位
  576. function getElementTop(element) {
  577. var actualTop = element.offsetTop;
  578. var current = element.offsetParent;
  579. while (current !== null) {
  580. actualTop += current.offsetTop;
  581. current = current.offsetParent;
  582. }
  583. return actualTop;
  584. }
  585. //主函数 由编辑窗上方的按钮调用,展开主列表
  586. function createFaceTexttable(ete) {
  587. if ($("#faceTextDiv").length == 0) {
  588. var ortt = ete.target;
  589. localStorage.FT_which_editor = (ortt.id == "editorButton") ? 'editorButton' : 'editorButton_lzl';
  590. var getTop = (ortt.id == "editorButton") ? getElementTop(ortt) + 32 : getElementTop(ortt) + 20;
  591. //定位主列表位置
  592. if ($('#tb_rich_poster').css('position')=='fixed' && ortt.id == "editorButton") { //原子的悬浮窗
  593. var faceTextDiv = $("<div>", {
  594. id : "faceTextDiv"
  595. }).css({
  596. "position" : "fixed",
  597. "z-index" : "10002",
  598. "left" : getElementLeft(ortt) - 300,
  599. "bottom" : "0px"
  600. }).appendTo(document.body);
  601. } else if (ortt.id == "editorButton_lzl") { //楼中楼回复
  602. var faceTextDiv = $("<div>", {
  603. id : "faceTextDiv"
  604. }).css({
  605. "position" : "absolute",
  606. "z-index" : "9999",
  607. "left" : getElementLeft(ortt) - 300,
  608. "top" : getTop - 300
  609. }).appendTo(document.body);
  610. } else { //主窗
  611. content.scrollTo(0, 99999);
  612. var faceTextDiv = $("<div>", {
  613. id : "faceTextDiv"
  614. }).css({
  615. "position" : "absolute",
  616. "z-index" : "9999",
  617. "left" : getElementLeft(ortt) - 300,
  618. "top" : getTop
  619. }).appendTo(document.body);
  620. }
  621. //建表
  622. var atTable = crE("table");
  623. atTable.setAttribute("border", "1");
  624. atTable.setAttribute("bordercolor", "#B8B3FF");
  625. atTable.setAttribute("cellpadding", "6");
  626. getId("faceTextDiv").appendChild(atTable);
  627. //TR
  628. var tdLeftName = ["愤怒啊", "不高兴", "哭、苦", "欢喜悦", "狗熊猫", "其它类", "自定义", "快输入"]
  629. for (lk = 0; lk < 8; lk++) {
  630. var creaFttr = crE("tr");
  631.  
  632. var tdLeft = crE("td");
  633. var tdLeftDiv = crE("div");
  634. tdLeftDiv.className = "FTLeftDiv";
  635. tdLeftDiv.id = "tdLeftDiv" + lk;
  636. tdLeftDiv.innerHTML = tdLeftName[lk];
  637. tdLeftDiv.title = "点击可编辑";
  638. if (lk == 7) {
  639. tdLeftDiv.addEventListener("click", promptEasyInsert, false);
  640. } else {
  641. tdLeftDiv.addEventListener("click", promptUserFT, false);
  642. }
  643. tdLeft.appendChild(tdLeftDiv);
  644.  
  645. var tdRight = crE("td");
  646. var tdRightDiv = crE("div");
  647. tdRightDiv.className = "FTRightDiv";
  648. tdRightDiv.id = "tdRightDiv" + lk;
  649. tdRight.appendChild(tdRightDiv);
  650.  
  651. creaFttr.appendChild(tdLeft);
  652. creaFttr.appendChild(tdRight);
  653. atTable.appendChild(creaFttr);
  654. }
  655.  
  656. //关闭按钮
  657. var closeFTDivbt = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA8UlEQVR42pWSMQrCQBBFcwPvI3gNKwtvYGVhaStqJYiFjY0IFmIrWEXRFIISiIqohYUYFcTC1gc/BFkSEmGyzMz/f3ZmNlaxMSvU7JQG2eJzdvdEW3j++vgstZ1AsNz6OgHkG6EpCFPe5S2qjHBzfgGZAuLV4TGw952Rg6MMVEKSZEyB7V6BW8NlJlcu1ccUPt0+1e6UkBMIgtkSKUi9iStSsz/H4SQJFD00ALXRZPMV2FxISDJ2S2qMpiVggFhB2BJsjaEB0ES3FO4k7dAqQHmm/F0rISMBRWxJjFQPF8IC9DsYoV42EOAlGtdyWyD4y76WWDtXsJol3gAAAABJRU5ErkJggg==";
  658. $("<span>", {
  659. class : "closeFTDivbt",
  660. click : closeFaceTxttable,
  661. html : "<img src='" + closeFTDivbt + "' alt='X' />"
  662. }).appendTo("#tdRightDiv0");
  663.  
  664. //载入各种颜文字到列表中
  665. loadThe("all");
  666. }
  667. }
  668. //关闭输入窗列表
  669. function closeFaceTxttable() {
  670. $(".insertFacetxt").detach();
  671. $(".FTRightDiv").detach();
  672. $(".FTLeftDiv").detach();
  673. $("#faceTextDiv").detach();
  674. }
  675.  
  676. //主编辑器添加按钮
  677. addNodeInsertedListener('.edui-btn-toolbar', function () {
  678. if (!document.getElementById("editorButton")) {
  679. $("<div>", {
  680. id : "editorButton",
  681. html : "('ェ ' )",
  682. click : createFaceTexttable
  683. }).appendTo(this);
  684. }
  685. })
  686.  
  687.  
  688. //楼中楼加按钮
  689. if (window.location.href.indexOf("/p/") != -1 || window.location.href.indexOf("ct=") != -1 || window.location.href.indexOf("kz=") != -1) {
  690. addNodeInsertedListener('.lzl_panel_wrapper>tbody>tr>td:first-child', function () {
  691. if (!getId("editorButton_lzl")) {
  692. $("<eas>", {
  693. id : "editorButton_lzl",
  694. html : "('ェ ' )",
  695. click : createFaceTexttable
  696. }).appendTo(this);
  697. }
  698. });
  699. }

QingJ © 2025

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