tieba_faceText

百度贴吧颜文字

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

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