From ac9423b99b974dfeb0b32da244a95d1cd05922c1 Mon Sep 17 00:00:00 2001 From: Lkytal Date: Sat, 15 Nov 2014 17:37:20 +0800 Subject: [PATCH] tieba 6.0 --- meta/select.meta.js | 2 +- meta/tieba_enhance.meta.js | 4 +- select.user.js | 58 ++--- tieba_enhance.user.js | 452 +++++++++++-------------------------- 4 files changed, 162 insertions(+), 354 deletions(-) diff --git a/meta/select.meta.js b/meta/select.meta.js index dcac553..b0739d4 100644 --- a/meta/select.meta.js +++ b/meta/select.meta.js @@ -4,7 +4,7 @@ // @author lkytal // @homepage http://lkytal.github.io/ // @icon http://lkytal.qiniudn.com/ic.ico -// @version 1.0.2 +// @version 1.1.0 // @description Select like opera // @include * // @grant unsafeWindow diff --git a/meta/tieba_enhance.meta.js b/meta/tieba_enhance.meta.js index 001dee3..c6c26a7 100644 --- a/meta/tieba_enhance.meta.js +++ b/meta/tieba_enhance.meta.js @@ -2,10 +2,10 @@ // @name Tieba Enhance // @namespace lkytal // @author lkytal -// @description 贴吧小尾巴, 坟贴提醒, 去除跳转, 最近表情等功能 +// @description 贴吧小尾巴, 坟贴提醒, 去除跳转等功能 // @include http://tieba.baidu.com/* // @include https://tieba.baidu.com/* -// @version 5.9.7 +// @version 6.0.0 // @author lkytal // @require http://code.jquery.com/jquery-2.1.1.min.js // @icon http://lkytal.qiniudn.com/ic.ico diff --git a/select.user.js b/select.user.js index 754158d..a2f2276 100644 --- a/select.user.js +++ b/select.user.js @@ -4,7 +4,7 @@ // @author lkytal // @homepage http://lkytal.github.io/ // @icon http://lkytal.qiniudn.com/ic.ico -// @version 1.0.2 +// @version 1.1.0 // @description Select like opera // @include * // @grant unsafeWindow @@ -16,7 +16,7 @@ // ==/UserScript== selectLikeOpera = function() { - var f = function(a) { + var findHTMLAchor = function(a) { if (a.nodeType === 3) a = a.parentNode; do { if (a.constructor === HTMLAnchorElement) return a; @@ -24,16 +24,16 @@ selectLikeOpera = function() { return null; }; - var g = function(e) { + var preventEvent = function(e) { e.preventDefault(); e.stopPropagation(); return false; }; - var h = (function() { + var rangeOperator = (function() { var w = typeof InstallTrigger === 'undefined'; return { - qq: function(x, y) { + createRange: function(x, y) { if (w) { return document.caretRangeFromPoint(x, y) } @@ -44,15 +44,15 @@ selectLikeOpera = function() { a.setStart(p.offsetNode, p.offset); return a; } - return null + return null; }, - qr: ((w ? '-webkit-' : '-moz-') + 'user-select') + rangeAttr: ((w ? '-webkit-' : '-moz-') + 'user-select') } })(); var j = (function() { var o = [{ - p: h.qr, + p: rangeOperator.rangeAttr, v: 'text' }, { p: 'outline-width', @@ -79,19 +79,19 @@ selectLikeOpera = function() { } })(); - var toggleEvent = function(a, b) { - if (b === undefined) b = true; - if (a.constructor !== Array) a = [a]; + var toggleEvent = function(events, bAdd) { + if (bAdd === undefined) bAdd = true; + if (events.constructor !== Array) events = [events]; - for (var i = 0, len = a.length; i < len; i += 1) + for (var i = 0, len = events.length; i < len; i += 1) { - if (b) + if (bAdd) { - document.addEventListener(a[i], E[a[i]], true); + document.addEventListener(events[i], eventList[events[i]], true); } else { - document.removeEventListener(a[i], E[a[i]], true); + document.removeEventListener(events[i], eventList[events[i]], true); } } }; @@ -105,23 +105,23 @@ selectLikeOpera = function() { u = z = false; }; - var B, s = document.getSelection(); + var B, selected = document.getSelection(); selectEvent = function(e) { if (e.which < 2) { A(); var x = e.clientX, y = e.clientY; - if (s.rangeCount > 0) { - var a = s.getRangeAt(0); + if (selected.rangeCount > 0) { + var a = selected.getRangeAt(0); if (!a.collapsed) { - var r = h.qq(x, y); + var r = rangeOperator.createRange(x, y); if (r && a.isPointInRange(r.startContainer, r.startOffset)) return; } } j(); var t = e.target, - n = f(t); + n = findHTMLAchor(t); if (!n) n = t.nodeType !== 3 ? t : t.parentNode; if (n.constructor === HTMLCanvasElement || n.textContent === '') return; var r = n.getBoundingClientRect(); @@ -142,7 +142,7 @@ selectLikeOpera = function() { var D = 3, K = 0.8, - E = { + eventList = { 'mousemove': function(e) { if (B) { if (B.c++ < 12) { @@ -150,7 +150,7 @@ selectLikeOpera = function() { if (Math.round(r.left) !== B.x || Math.round(r.top) !== B.y) { removeEvent(['mousemove', 'mouseup', 'dragend', 'dragstart', 'click']); j(); - s.removeAllRanges(); + selected.removeAllRanges(); return; } } else { @@ -160,11 +160,11 @@ selectLikeOpera = function() { var x = e.clientX, y = e.clientY; if (v) { - s.removeAllRanges(); + selected.removeAllRanges(); var a = x > m.x ? -2 : 2; - var b = h.qq(x + a, y); + var b = rangeOperator.createRange(x + a, y); if (b) { - s.addRange(b); + selected.addRange(b); v = false; } } @@ -179,13 +179,13 @@ selectLikeOpera = function() { } } if (u) { - var b = h.qq(x, y); - if (b) s.extend(b.startContainer, b.startOffset); + var b = rangeOperator.createRange(x, y); + if (b) selected.extend(b.startContainer, b.startOffset); } }, 'dragstart': function(e) { removeEvent('dragstart'); - if (u) return g(e); + if (u) return preventEvent(e); }, 'mouseup': function(e) { removeEvent(['mousemove', 'mouseup', 'dragstart', 'dragend']); @@ -199,7 +199,7 @@ selectLikeOpera = function() { }, 'click': function(e) { removeEvent('click'); - if (z) return g(e); + if (z) return preventEvent(e); } }; diff --git a/tieba_enhance.user.js b/tieba_enhance.user.js index 6910c75..14005af 100644 --- a/tieba_enhance.user.js +++ b/tieba_enhance.user.js @@ -2,10 +2,10 @@ // @name Tieba Enhance // @namespace lkytal // @author lkytal -// @description 贴吧小尾巴, 坟贴提醒, 去除跳转, 最近表情等功能 +// @description 贴吧小尾巴, 坟贴提醒, 去除跳转等功能 // @include http://tieba.baidu.com/* // @include https://tieba.baidu.com/* -// @version 5.9.7 +// @version 6.0.0 // @author lkytal // @require http://code.jquery.com/jquery-2.1.1.min.js // @icon http://lkytal.qiniudn.com/ic.ico @@ -22,232 +22,60 @@ // ==/UserScript== "use strict"; -var CheckPost, NodeInsertListener, SmileConfig, SmileInit, TailInit, checkFather, clearLink, fentie_date, fentie_forbidden, fentie_open, maxCount, maxHeight, maxWidth, open_setting_window, saveConfig, smiley_delay, smiley_height, smiley_max, smiley_open, smiley_width, tail_data, tail_open, tiebaData, x, _style_setted, +var CheckPost, Init, TailInit, clearLink, count, log, open_setting_window, tiebaData, __hasProp = {}.hasOwnProperty; -tiebaData = { - StopPost: 0 -}; - -smiley_open = GM_getValue("smiley_open", 1); - -smiley_height = GM_getValue("smiley_height", 500); - -smiley_width = GM_getValue("smiley_width", 500); - -smiley_delay = GM_getValue("smiley_delay", 240); - -smiley_max = GM_getValue("smiley_max", 20); - -fentie_open = GM_getValue("fentie_open", 1); - -fentie_date = GM_getValue("fentie_date", 30); - -fentie_forbidden = GM_getValue("fentie_forbidden", 1); +count = 0; -tail_open = GM_getValue("tail_open", 1); - -tiebaData.tail_cur = GM_getValue("tail_cur", ""); - -tail_data = JSON.parse(GM_getValue("tail_data", "{\"Default\":\" !分隔!html\"}")); - -maxCount = smiley_max; - -maxHeight = smiley_height; - -maxWidth = smiley_width; - -_style_setted = 0; - -if (GM_getValue("tail_adopt", 0) < 2) { - GM_setValue("tail_adopt", 2); - if (typeof localStorage["tail_data"] === "string") { - GM_setValue("tail_data", localStorage["tail_data"]); - tail_data = JSON.parse(localStorage["tail_data"]); - } - GM_setValue("smiley_open", smiley_open); - GM_setValue("smiley_height", smiley_height); - GM_setValue("smiley_width", smiley_width); - GM_setValue("smiley_delay", smiley_delay); - GM_setValue("smiley_max", smiley_max); - GM_setValue("fentie_open", fentie_open); - GM_setValue("fentie_date", fentie_date); - GM_setValue("fentie_forbidden", fentie_forbidden); - GM_setValue("tail_open", tail_open); - GM_setValue("tail_data", JSON.stringify(tail_data)); - for (x in tail_data) { - tail_data[x] = tail_data[x].replace(/!逗号!/g, ",").replace(/!引号!/g, "\""); +log = function(msg) { + var text; + count += 1; + text = "hit at : " + count; + if (msg != null) { + text = "hit " + count + " : " + msg; } -} - -saveConfig = function() { - GM_setValue("tieba_smile_config", JSON.stringify(SmileConfig)); -}; - -NodeInsertListener = function(selector, callback, once) { - var cssString, handler, id; - cssString = " { animation-name: listener{id};animation-duration: 0.001s;} @keyframes listener{id} { from { opacity: 0.99; } to {opacity: 1; } }"; - id = new Date().getTime(); - GM_addStyle(selector + cssString.replace(/\{id\}/g, id)); - handler = (function(e) { - if (e.animationName === "listener" + id) { - if (once) { - this.stop(); - } - callback(e.target); - } - }).bind(this); - this.stop = function() { - removeEventListener("animationend", handler); - }; - addEventListener("animationend", handler); -}; - -SmileInit = function() { - new NodeInsertListener(".edui-btn-emotion", function() { - var mousein, panel, pushImages; - panel = unsafeWindow.$.eduipopup().clone().appendTo(".edui-dialog-container").attr("style", "z-index: 1; display: none; top: 44px; left: -3px; position: absolute;"); - panel.find(".edui-popup-caret").addClass("up").attr("style", "top: -8px; left: 247px; position: absolute;"); - unsafeWindow._.Module.use("common/component/UeditorEmotion", [ - { - container: $("
") - } - ], function(h) { - var content; - content = h.$container.appendTo(panel.find(".edui-popup-body")); - content.find(".s_layer_tab.j_tab.ueditor_emotion_tab").remove(); - NodeInsertListener("table", (function() { - var cell, pushImages, table; - table = content.find("table tbody"); - cell = table.find(".j_emotion").eq(0).clone().removeClass("face").empty().css("cursor", "pointer").click(function() { - unsafeWindow.test_editor.execCommand("inserthtml", ""); - panel.hide(); - }).append($("").css("max-height", "54px").css("max-width", "54px")); - GM_addStyle(".review { max-height: 60px; max-width: 60px; }"); - table.parent().before($("
ctrl + 左键点击删除表情
")); - pushImages = function() { - var i; - table.empty(); - i = 0; - while (i < SmileConfig.length / 10) { - table.append($("").append($(SmileConfig.slice(10 * i, 10 * (i + 1)).map(function(img) { - var newCell; - newCell = cell.clone(true).data("surl", img); - newCell.find("img").attr("src", img); - return newCell.get(0); - })))); - i++; - } - table.find("img").click(function(event) { - if (event.ctrlKey) { - SmileConfig.splice(SmileConfig.indexOf($(this).attr("src")), 1); - GM_setValue("tieba_smile_config", JSON.stringify(SmileConfig)); - $(this).parent().remove(); - event.preventDefault(); - event.stopPropagation(); - } - }); - }; - pushImages(); - }), true); - }); - pushImages = function() {}; - mousein = false; - $(".edui-btn-emotion").click(function() { - panel.hide(); - mousein = false; - }).add(panel).mouseenter(function() { - panel.show(); - mousein = true; - }).mouseleave(function() { - mousein = false; - setTimeout((function() { - if (!mousein) { - panel.hide(); - } - }), 300); - }); - NodeInsertListener("#ueditor_replace img", function(node) { - var i, idp, img; - if (node.width <= maxWidth && node.height <= maxHeight) { - img = node.src; - if (img.indexOf("data:image") !== -1) { - return; - } - if (img.indexOf("static.tieba.baidu.com/tb/editor/images/face/") !== -1) { - idp = img.lastIndexOf("?t="); - img = img.slice(0, idp); - } - i = SmileConfig.indexOf(img); - if (i !== -1) { - SmileConfig.splice(i, 1); - } else { - if (SmileConfig.length === maxCount) { - SmileConfig.pop(); - } - } - SmileConfig.unshift(img); - saveConfig(); - pushImages(); - } - }); - }, true); + return console.log(text); }; -checkFather = function(that, e) { - var parent; - parent = e.relatedTarget; - try { - while (parent && parent !== that) { - parent = parent.parentNode; - } - return parent !== that; - } catch (_error) {} +tiebaData = { + StopPost: 0 }; open_setting_window = function() { - var e, _tmp; - if (_style_setted === 0) { + var e, x, _tmp; + if (tiebaData._style_setted === 0) { if (window.innerHeight <= 727) { GM_addStyle("#setting_window{top:50px;}#setting_out_div{max-height:" + (window.innerHeight - 227) + "px;}"); } else { GM_addStyle("#setting_window{top:" + ((window.innerHeight - 627) / 2) + "px;}#setting_out_div{max-height:500px;}"); } - _style_setted = 1; + tiebaData._style_setted = 1; } _tmp = document.createElement("div"); _tmp.id = "setting_shadow"; - _tmp.innerHTML += "
\n
重置
\n
保存
\n
设置
\n

\n
\n
最近使用的表情
\n
\n

最近使用的表情仅获取符合以下条件的图片

图片宽度≤\n 图片高度≤\n \n

最近使用的表情窗口弹出延迟

\n 延迟时间(毫秒)\n
清空最近表情
\n

\n 最大表情数量\n

\n

\n

点击表情后关闭窗口
\n
\n

\n
坟贴检测
\n
\n

超过\n 天的帖子视为坟贴\n
坟贴禁回
\n
\n

\n
小尾巴
\n
\n
\n
\n
\n
\n
\n
html
\n
javascript
\n
\n
\n
保存当前尾巴
\n
新建尾巴
\n
删除尾巴
\n
\n
\n 预览\n
\n

\n
\n
\n
"; + _tmp.innerHTML += "
\n
重置
\n
保存
\n
设置
\n

\n
\n
坟贴检测
\n
\n

超过\n 天的帖子视为坟贴\n
坟贴禁回
\n
\n

\n
小尾巴
\n
\n
\n
\n
\n
\n
\n
html
\n
javascript
\n
\n
\n
保存当前尾巴
\n
新建尾巴
\n
删除尾巴
\n
\n
\n 预览\n
\n

\n
\n
\n
"; document.body.appendChild(_tmp); - $("#smiley_height")[0].value = smiley_height; - $("#smiley_width")[0].value = smiley_width; - $("#smiley_delay")[0].value = smiley_width; - $("#smiley_max")[0].value = smiley_max; - $("#fentie_date")[0].value = fentie_date; - if (!smiley_open) { - $("#setting_sp_smiley").attr("class", "setting_sp_btn close"); - $("#setting_sp_smiley + div").css("display", "none"); - } - if (!fentie_open) { + $("#fentie_date")[0].value = tiebaData.fentie_date; + if (!tiebaData.fentie_open) { $("#fentie_open").attr("class", "setting_sp_btn close"); $("#fentie_open + div").css("display", "none"); } - if (!fentie_forbidden) { + if (!tiebaData.fentie_forbidden) { $("#fentie_forbidden").attr("class", "setting_sp_btn close"); } - if (!tail_open) { + if (!tiebaData.tail_open) { $("#tail_open").attr("class", "setting_sp_btn close"); $("#tail_select,#tail_select + div").css("display", "none"); } - for (x in tail_data) { + for (x in tiebaData.tail_data) { $("#tail_select_text")[0].innerHTML = x; $("#tail_select_text").attr("new", "0"); $("#tail_select_text").attr("oname", x); - $("#tail_data")[0].value = tail_data[x].split("!分隔!")[0]; - $("#tail_type_text")[0].innerHTML = tail_data[x].split("!分隔!")[1]; + $("#tail_data")[0].value = tiebaData.tail_data[x].split("!分隔!")[0]; + $("#tail_type_text")[0].innerHTML = tiebaData.tail_data[x].split("!分隔!")[1]; break; } - for (x in tail_data) { + for (x in tiebaData.tail_data) { $("#tail_option_box").append("
" + x + "
"); } $(".tail_option").click(function() { @@ -255,8 +83,8 @@ open_setting_window = function() { $("#tail_select_text")[0].innerHTML = this.innerHTML; $("#tail_select_text").attr("new", "0"); $("#tail_select_text").attr("oname", this.innerHTML); - $("#tail_data")[0].value = tail_data[this.innerHTML].split("!分隔!")[0]; - $("#tail_type_text")[0].innerHTML = tail_data[this.innerHTML].split("!分隔!")[1]; + $("#tail_data")[0].value = tiebaData.tail_data[this.innerHTML].split("!分隔!")[0]; + $("#tail_type_text")[0].innerHTML = tiebaData.tail_data[this.innerHTML].split("!分隔!")[1]; if ($("#tail_type_text")[0].innerHTML === "javascript") { try { $("#tail_data_show")[0].innerHTML = eval_($("#tail_data")[0].value); @@ -355,49 +183,34 @@ open_setting_window = function() { window.location.reload(); } }); - $("#setting_sp_smiley").click(function() { - $("#setting_sp_smiley + div").slideToggle("slow"); - if (smiley_open) { - smiley_open = 0; - $("#setting_sp_smiley").attr("class", "setting_sp_btn close"); - } else { - smiley_open = 1; - $("#setting_sp_smiley").attr("class", "setting_sp_btn"); - } - }); - $("#setting_clear_smiley").click(function() { - var SmileConfig; - SmileConfig = []; - GM_setValue("tieba_smile_config", JSON.stringify(SmileConfig)); - }); $("#fentie_open").click(function() { $("#fentie_open + div").slideToggle("slow"); - if (fentie_open) { - fentie_open = 0; + if (tiebaData.fentie_open) { + tiebaData.fentie_open = 0; $("#fentie_open").attr("class", "setting_sp_btn close"); } else { - fentie_open = 1; + tiebaData.fentie_open = 1; $("#fentie_open").attr("class", "setting_sp_btn"); } }); $("#fentie_forbidden").click(function() { - if (fentie_forbidden) { - fentie_forbidden = 0; + if (tiebaData.fentie_forbidden) { + tiebaData.fentie_forbidden = 0; $("#fentie_forbidden").attr("class", "setting_sp_btn close"); } else { - fentie_forbidden = 1; + tiebaData.fentie_forbidden = 1; $("#fentie_forbidden").attr("class", "setting_sp_btn"); } }); $("#tail_open").click(function() { - if (tail_open) { - tail_open = 0; + if (tiebaData.tail_open) { + tiebaData.tail_open = 0; $("#tail_select,#tail_select + div").toggle("slow"); $("#tail_option_box").hide(400); $("#tail_type_box").hide(400); $("#tail_open").attr("class", "setting_sp_btn close"); } else { - tail_open = 1; + tiebaData.tail_open = 1; $("#tail_select,#tail_select + div").slideToggle("slow"); $("#tail_open").attr("class", "setting_sp_btn"); } @@ -435,28 +248,28 @@ open_setting_window = function() { var oname; oname = $("#tail_select_text")[0].getAttribute("oname"); if ($("#tail_select_text")[0].getAttribute("new") !== 1) { - delete tail_data[oname]; + delete tiebaData.tail_data[oname]; } - for (x in tail_data) { + for (x in tiebaData.tail_data) { $("#tail_select_text")[0].innerHTML = x; $("#tail_select_text").attr("new", "0"); $("#tail_select_text").attr("oname", x); - $("#tail_data")[0].value = tail_data[x].split("!分隔!")[0]; - $("#tail_type_text")[0].innerHTML = tail_data[x].split("!分隔!")[1]; + $("#tail_data")[0].value = tiebaData.tail_data[x].split("!分隔!")[0]; + $("#tail_type_text")[0].innerHTML = tiebaData.tail_data[x].split("!分隔!")[1]; break; } - GM_setValue("tail_data", JSON.stringify(tail_data)); + GM_setValue("tail_data", JSON.stringify(tiebaData.tail_data)); $("#tail_option_box").empty(); - for (x in tail_data) { - tail_data[x] = tail_data[x].replace(/!逗号!/g, ",").replace(/!引号!/g, "\""); + for (x in tiebaData.tail_data) { + tiebaData.tail_data[x] = tiebaData.tail_data[x].replace(/!逗号!/g, ",").replace(/!引号!/g, "\""); $("#tail_option_box").append("
" + x + "
"); } $(".tail_option").click(function() { $("#tail_select_text")[0].innerHTML = this.innerHTML; $("#tail_select_text").attr("new", "0"); $("#tail_select_text").attr("oname", this.innerHTML); - $("#tail_data")[0].value = tail_data[this.innerHTML].split("!分隔!")[0]; - $("#tail_type_text")[0].innerHTML = tail_data[this.innerHTML].split("!分隔!")[1]; + $("#tail_data")[0].value = tiebaData.tail_data[this.innerHTML].split("!分隔!")[0]; + $("#tail_type_text")[0].innerHTML = tiebaData.tail_data[this.innerHTML].split("!分隔!")[1]; if ($("#tail_type_text")[0].innerHTML === "javascript") { try { $("#tail_data_show")[0].innerHTML = eval_($("#tail_data")[0].value); @@ -476,35 +289,35 @@ open_setting_window = function() { name = $("#tail_select_text")[0].innerHTML; oname = $("#tail_select_text")[0].getAttribute("oname"); if ($("#tail_select_text")[0].getAttribute("new") === 1) { - if (tail_data[name]) { + if (tiebaData.tail_data[name]) { alert("该尾巴已存在!"); return; } else { - tail_data[name] = $("#tail_data")[0].value + "!分隔!" + $("#tail_type_text")[0].textContent; + tiebaData.tail_data[name] = $("#tail_data")[0].value + "!分隔!" + $("#tail_type_text")[0].textContent; } } else { if (name === oname) { - tail_data[name] = $("#tail_data")[0].value + "!分隔!" + $("#tail_type_text")[0].textContent; + tiebaData.tail_data[name] = $("#tail_data")[0].value + "!分隔!" + $("#tail_type_text")[0].textContent; } else { - delete tail_data[oname]; - tail_data[name] = $("#tail_data")[0].value + "!分隔!" + $("#tail_type_text")[0].textContent; + delete tiebaData.tail_data[oname]; + tiebaData.tail_data[name] = $("#tail_data")[0].value + "!分隔!" + $("#tail_type_text")[0].textContent; } } - for (x in tail_data) { - tail_data[x] = tail_data[x].replace(/,/g, "!逗号!").replace(/"/g, "!引号!"); + for (x in tiebaData.tail_data) { + tiebaData.tail_data[x] = tiebaData.tail_data[x].replace(/,/g, "!逗号!").replace(/"/g, "!引号!"); } - GM_setValue("tail_data", JSON.stringify(tail_data)); + GM_setValue("tail_data", JSON.stringify(tiebaData.tail_data)); $("#tail_option_box").empty(); - for (x in tail_data) { - tail_data[x] = tail_data[x].replace(/!逗号!/g, ",").replace(/!引号!/g, "\""); + for (x in tiebaData.tail_data) { + tiebaData.tail_data[x] = tiebaData.tail_data[x].replace(/!逗号!/g, ",").replace(/!引号!/g, "\""); $("#tail_option_box").append("
" + x + "
"); } $(".tail_option").click(function() { $("#tail_select_text")[0].innerHTML = this.innerHTML; $("#tail_select_text").attr("new", "0"); $("#tail_select_text").attr("oname", this.innerHTML); - $("#tail_data")[0].value = tail_data[this.innerHTML].split("!分隔!")[0]; - $("#tail_type_text")[0].innerHTML = tail_data[this.innerHTML].split("!分隔!")[1]; + $("#tail_data")[0].value = tiebaData.tail_data[this.innerHTML].split("!分隔!")[0]; + $("#tail_type_text")[0].innerHTML = tiebaData.tail_data[this.innerHTML].split("!分隔!")[1]; if ($("#tail_type_text")[0].innerHTML === "javascript") { try { $("#tail_data_show")[0].innerHTML = eval_($("#tail_data")[0].value); @@ -520,20 +333,11 @@ open_setting_window = function() { }); }); $("#setting_save").click(function() { - smiley_height = $("#smiley_height")[0].value; - smiley_width = $("#smiley_width")[0].value; - smiley_delay = $("#smiley_delay")[0].value; - smiley_max = $("#smiley_max")[0].value; - fentie_date = $("#fentie_date")[0].value; - GM_setValue("smiley_open", smiley_open); - GM_setValue("smiley_height", smiley_height); - GM_setValue("smiley_width", smiley_width); - GM_setValue("smiley_delay", smiley_delay); - GM_setValue("smiley_max", smiley_max); - GM_setValue("fentie_open", fentie_open); - GM_setValue("fentie_date", fentie_date); - GM_setValue("fentie_forbidden", fentie_forbidden); - GM_setValue("tail_open", tail_open); + tiebaData.fentie_date = $("#fentie_date")[0].value; + GM_setValue("fentie_open", tiebaData.fentie_open); + GM_setValue("fentie_date", tiebaData.fentie_date); + GM_setValue("fentie_forbidden", tiebaData.fentie_forbidden); + GM_setValue("tail_open", tiebaData.tail_open); $("#setting_window")[0].style.top = "-600px"; setTimeout((function() { $("#setting_shadow").css("opacity", "0"); @@ -547,7 +351,7 @@ open_setting_window = function() { CheckPost = function() { var css, date_str, date_time, days, prefix, years; - if ($("#j_core_title_wrap").length && fentie_open) { + if ($("#j_core_title_wrap").length && tiebaData.fentie_open) { date_str = $("#j_p_postlist ul.p_tail > li:nth-child(2) > span")[0].textContent; if (date_str === "1970-01-01 07:00") { setTimeout(CheckPost, 500); @@ -556,7 +360,7 @@ CheckPost = function() { date_str = date_str.replace(" ", "-").replace(":", "-").split("-"); date_time = new Date(date_str[0], date_str[1] - 1, date_str[2], date_str[3], date_str[4]); days = parseInt((new Date() - date_time) / 86400000); - if (days >= fentie_date) { + if (days >= tiebaData.fentie_date) { prefix = days; if (days >= 365) { years = parseInt(days / 365); @@ -565,64 +369,20 @@ CheckPost = function() { css = "#NotifyTide{width: 100%;text-align: center;color: white;font-size: 28px;vertical-align: middle;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;} #NotifyTide p{background: rgba(255, 119, 119, .5);padding: 25px 0px 25px 0px;text-shadow: red 0 0 5px,red 0 0 5px,red 0 0 7px,red 0 0 7px,red 0 0 10px,red 0 0 10px,red 0 0 15px,red 0 0 15px;}"; GM_addStyle(css); $("#tb_nav").after("

这是一个" + prefix + "天的坟贴哦~

"); - if (fentie_forbidden) { + if (tiebaData.fentie_forbidden) { return tiebaData.StopPost = 1; } } } }; -setTimeout(CheckPost, 800); - - -/* -ClearLink = -> - for link in document.querySelectorAll('a[href^="http://jump.bdimg.com"]') - url = link.textContent - url = "http://" + url if url.indexOf("http") isnt 0 - link.href = url - return - -setTimeout ClearLink, 1000 - */ - -if (!GM_getValue("tieba_smile_config")) { - SmileConfig = ["http://imgsrc.baidu.com/forum/pic/item/8989a544ebf81a4c82fc0a3ad72a6059272da6b6.jpg", "http://imgsrc.baidu.com/forum/pic/item/5f0e68ed2e738bd42bb054c2a18b87d6257ff9ef.jpg", "http://imgsrc.baidu.com/forum/pic/item/16a9927eca806538e37b42e097dda144af3482ef.jpg", "http://imgsrc.baidu.com/forum/pic/item/dcc451da81cb39dbe027d6f6d0160924aa1830ae.jpg", "http://imgsrc.baidu.com/forum/pic/item/a5be42fbfbedab64aa7b3a14f736afc378311e0d.jpg"]; - GM_setValue("tieba_smile_config", JSON.stringify(SmileConfig)); -} - -SmileConfig = JSON.parse(GM_getValue("tieba_smile_config")); - -$("#tb_nav").find("ul:first").append("
  • \n
    \n
    \n 设置\n
    \n
    \n
  • "); - -$("#setting_btn").click(function() { - return open_setting_window(); -}); - -clearLink = function(event) { - var link, url; - link = event.target; - if (link.href.indexOf("http://jump.bdimg.com/safecheck") === 0) { - url = link.textContent; - if (url.indexOf("http") !== 0) { - url = "http://" + url; - } - return link.href = url; - } -}; - -jQuery("body").on("mouseover", "a", clearLink); - TailInit = function() { - var AddTail, SendBt, i; + var AddTail, SendBt, i, x, _ref, _ref1; if (document.querySelector(".ui_btn.ui_btn_m.j_submit.poster_submit")) { - if (smiley_open) { - SmileInit(); - } - if (!tail_open) { + if (!tiebaData.tail_open) { return; } - $(".poster_posting_status.j_posting_status").after("\n \n
    \n
    \n
    \n
    "); + $("a.j_submit.poster_submit").before("\n \n
    \n
    \n
    \n
    "); $("#tail_use_text").click(function() { return $("#tail_use_box").slideToggle(400); }); @@ -633,9 +393,10 @@ TailInit = function() { }); if (tiebaData.tail_cur === "不使用小尾巴" || tiebaData.tail_cur === "随机小尾巴") { $("#tail_use_text")[0].innerHTML = tiebaData.tail_cur; - } else if (typeof tail_data[tiebaData.tail_cur] === "undefined") { - for (i in tail_data) { - if (!__hasProp.call(tail_data, i)) continue; + } else if (typeof tiebaData.tail_data[tiebaData.tail_cur] === "undefined") { + _ref = tiebaData.tail_data; + for (i in _ref) { + if (!__hasProp.call(_ref, i)) continue; if (!(i != null)) { continue; } @@ -649,8 +410,9 @@ TailInit = function() { } $("#tail_use_box").append("
    不使用小尾巴
    "); $("#tail_use_box").append("
    随机小尾巴
    "); - for (x in tail_data) { - if (!__hasProp.call(tail_data, x)) continue; + _ref1 = tiebaData.tail_data; + for (x in _ref1) { + if (!__hasProp.call(_ref1, x)) continue; $("#tail_use_box").append("
    " + x + "
    "); } $(".tail_use_option").click(function() { @@ -670,10 +432,11 @@ TailInit = function() { } if (tiebaData.tail_cur === "随机小尾巴") { tailList = (function() { - var _results; + var _ref2, _results; + _ref2 = tiebaData.tail_data; _results = []; - for (key in tail_data) { - value = tail_data[key]; + for (key in _ref2) { + value = _ref2[key]; _results.push(value); } return _results; @@ -681,11 +444,11 @@ TailInit = function() { tiebaData.tail_cur = tailList[parseInt(Math.random() * tailList.length)]; } tailContent = void 0; - if (tail_data[tiebaData.tail_cur].split("!分隔!")[1] === "html") { - tailContent = tail_data[tiebaData.tail_cur].split("!分隔!")[0]; + if (tiebaData.tail_data[tiebaData.tail_cur].split("!分隔!")[1] === "html") { + tailContent = tiebaData.tail_data[tiebaData.tail_cur].split("!分隔!")[0]; } else { - if (tail_data[tiebaData.tail_cur].split("!分隔!")[1] === "javascript") { - tailContent = eval(tail_data[tiebaData.tail_cur].split("!分隔!")[0]); + if (tiebaData.tail_data[tiebaData.tail_cur].split("!分隔!")[1] === "javascript") { + tailContent = eval(tiebaData.tail_data[tiebaData.tail_cur].split("!分隔!")[0]); } } return $("#ueditor_replace").append("
    " + tailContent); @@ -702,8 +465,53 @@ TailInit = function() { } }; +clearLink = function(event) { + var link, url; + link = event.target; + if (link.href.indexOf("http://jump.bdimg.com/safecheck") === 0) { + url = link.textContent; + if (url.indexOf("http") !== 0) { + url = "http://" + url; + } + return link.href = url; + } +}; + +Init = function() { + var x; + tiebaData.fentie_open = GM_getValue("fentie_open", 1); + tiebaData.fentie_date = GM_getValue("fentie_date", 30); + tiebaData.fentie_forbidden = GM_getValue("fentie_forbidden", 1); + tiebaData.tail_open = GM_getValue("tail_open", 1); + tiebaData.tail_cur = GM_getValue("tail_cur", ""); + tiebaData.tail_data = JSON.parse(GM_getValue("tail_data", "{\"Default\":\" !分隔!html\"}")); + tiebaData._style_setted = 0; + if (GM_getValue("tail_adopt", 0) < 2) { + GM_setValue("tail_adopt", 2); + if (typeof localStorage["tail_data"] === "string") { + GM_setValue("tail_data", localStorage["tail_data"]); + tiebaData.tail_data = JSON.parse(localStorage["tail_data"]); + } + GM_setValue("fentie_open", tiebaData.fentie_open); + GM_setValue("fentie_date", tiebaData.fentie_date); + GM_setValue("fentie_forbidden", tiebaData.fentie_forbidden); + GM_setValue("tail_open", tiebaData.tail_open); + GM_setValue("tail_data", JSON.stringify(tiebaData.tail_data)); + for (x in tiebaData.tail_data) { + tiebaData.tail_data[x] = tiebaData.tail_data[x].replace(/!逗号!/g, ",").replace(/!引号!/g, "\""); + } + } + $("#tb_nav").find("ul:first").append("
  • \n
    \n
    \n 设置\n
    \n
    \n
  • "); + jQuery("body").on("mouseover", "a", clearLink); + setTimeout(CheckPost, 800); + $("#setting_btn").click(function() { + return open_setting_window(); + }); + TailInit(); +}; + if (window === window.top && window.document.title !== "") { - setTimeout(TailInit, 120); + setTimeout(Init, 120); } -GM_addStyle(".smiley {\n position: relative;\n}\n.lzl_panel_wrapper {\n position: relative !important;\n}\n#recent_img {\n -moz-box-sizing: border-box !important;\n position: absolute;\n min-height: 90px;\n background: #FFF;\n border: 1px solid #999;\n box-shadow: 0 0 3px #999;\n z-index: 1;\n top: 50px;\n left: 0;\n text-align: center;\n padding: 6px;\n -moz-user-select: none;\n cursor: default;\n}\n#recent_img.lzl {\n left: auto;\n right: 0px;\n}\n#recent_img > p {\n line-height: 25px;\n font-size: 15px;\n color: #111;\n height: 30px;\n -moz-user-select: none;\n cursor: default;\n}\n#recent_img > div {\n cursor: pointer;\n display: inline-block;\n margin: 2px;\n overflow: hidden;\n width: 50px;\n height: 50px;\n float: left;\n background-position: 50% 50%;\n background-repeat: no-repeat;\n -moz-transition: 0.15s;\n}\n#recent_img > div:hover {\n box-shadow: 0 0 2px #999;\n}\n#recent_img > div:active {\n box-shadow: 0 0 3px #444;\n}\n#setting_shadow {\n position: fixed;\n z-index: 1024000000;\n bottom: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.6);\n -moz-transition: 0.4s;\n}\n#setting_window {\n position: fixed;\n left: -moz-calc(50% - 320px);\n left: -webkit-calc(50% - 320px);\n width: 600px;\n background: #FFF;\n box-shadow: 0 0 5px #222;\n padding: 20px 20px 50px 20px;\n z-index: 1000000000;\n -moz-transition: 0.4s ease all;\n}\n#setting_out_div {\n overflow-y: scroll;\n padding: 0 10px 0 0;\n}\n.setting_btn_inside {\n font-size: 16px;\n padding: 4px;\n -moz-user-select: none;\n cursor: default;\n}\n.setting_btn_inside:hover {\n background: #DDD;\n}\n.setting_btn_inside:active {\n box-shadow: 0 0 3px #999 inset;\n}\n#setting_reset {\n position: absolute;\n top: 14px;\n right: 14px;\n}\n#setting_save {\n display: inline-block;\n position: absolute;\n right: 15px;\n bottom: 10px;\n}\n#setting_clear_smiley {\n display: inline-block;\n right: 22px;\n float: right;\n}\n.setting_sp_btn {\n font-size: 12px;\n padding: 4px;\n -moz-user-select: none;\n cursor: default;\n display: inline-block;\n position: relative;\n}\n.setting_sp_btn.close {\n background: #DDD;\n}\n.setting_sp_btn::before {\n position: absolute;\n right: -26px;\n top: 0;\n content: \"\";\n width: 26px;\n height: 26px;\n background: #6B4;\n -moz-transition: 0.3s;\n}\n.setting_sp_btn.close::before {\n background: #C54;\n}\n.setting_sp_btn:hover {\n background: #DDD;\n}\n.setting_sp_btn:active {\n box-shadow: 0 0 3px #999 inset;\n}\n#setting_sp_q_c {\n margin: 0 0 0 40px !important;\n}\n#setting_window .setting_title {\n font-size: 34px;\n height: 42px;\n line-height: 42px;\n padding: 7px 10px;\n margin: 0 0 0 -7px;\n -moz-user-select: none;\n cursor: default;\n display: inline-block;\n}\n#setting_window p {\n font-size: 18px;\n height: 42px;\n line-height: 50px;\n -moz-user-select: none;\n cursor: default;\n}\n#setting_window p.setting_hide {\n height: 10px;\n line-height: 10px;\n -moz-user-select: none;\n cursor: default;\n}\n#setting_window p.setting_hide.sp {\n background: #CCC !important;\n height: 1px !important;\n margin: 8px 0 !important;\n}\n#setting_window p.setting_hiding_sp {\n height: 1px;\n line-height: 1px;\n -moz-user-select: none;\n cursor: default;\n}\n#setting_window .setting_input {\n -moz-appearance: none;\n border: none;\n background: #DDD;\n height: 28px;\n padding: 0px 7px !important;\n width: 100px;\n margin: 0 10px 0 0 !important;\n font-size: 14px !important;\n}\n#setting_window span {\n font-size: 14px !important;\n margin: 0 10px 0 0 !important;\n -moz-user-select: none;\n cursor: default;\n display: inline-block;\n}\n.setting_textarea {\n -moz-appearance: none !important;\n border: none;\n background: #DDD;\n margin: 10px 0 0 0 !important;\n padding: 7px !important;\n width: 550px;\n height: 100px;\n -moz-box-sizing: border-box;\n font-size: 12px !important;\n}\n#tail_select {\n display: inline-block;\n height: 26px !important;\n line-height: 26px !important;\n width: 450px !important;\n margin: 0px 0 0 40px !important;\n vertical-align: top !important;\n text-align: center !important;\n font-size: 12px !Important;\n -moz-box-sizing: border-box !Important;\n position: relative !important;\n cursor: default !important;\n}\n#tail_select_text {\n height: 26px;\n float: left;\n min-width: 100px !important;\n background: #DDD !important;\n padding: 0 5px !important;\n -moz-box-sizing: border-box !Important;\n}\n#tail_option_box {\n float: left;\n position: absolute !important;\n bottom: 30px;\n left: 0;\n min-width: 100px;\n background: #EEE !important;\n box-shadow: 0 0 3px #666 !important;\n display: inline-block;\n}\n.tail_option {\n padding: 0 8px !important;\n width: auto !important;\n font-size: 12px !important;\n height: 24px !important;\n line-height: 24px !important;\n cursor: default !important;\n}\n.tail_option:hover {\n background: #DDD !important;\n}\n#tail_type {\n background: #DDD !important;\n position: absolute !important;\n top: 0;\n right: 0px;\n}\n#tail_type_text {\n width: 80px !important;\n text-align: center !important;\n}\n#tail_type_box {\n position: absolute !important;\n width: 80px !important;\n bottom: 30px;\n right: 0px;\n background: #EEE;\n box-shadow: 0 0 3px #666;\n}\n.tail_type_option:hover {\n background: #DDD;\n}\n#tail_save {\n font-size: 12px !important;\n position: absolute;\n top: 0;\n right: 90px;\n height: 26px !important;\n padding: 0 !important;\n width: 86px !important;\n}\n#tail_new {\n font-size: 12px !important;\n -moz-box-sizing: border-box !Important;\n padding: 0 !important;\n height: 26px !important;\n width: 60px !important;\n position: absolute !important;\n top: 0 !important;\n right: 180px !important;\n}\n#tail_delete {\n font-size: 12px !important;\n -moz-box-sizing: border-box !Important;\n padding: 0 !important;\n height: 26px !important;\n width: 60px !important;\n position: absolute !important;\n top: 0 !important;\n right: 250px !important;\n}\n#tail_data + span {\n display: block !Important;\n margin: 5px 0 -3px 0 !important;\n font-size: 12px !Important;\n}\n#tail_use {\n display: inline-block !important;\n background: #EEE;\n height: 30px;\n width: auto;\n position: relative !important;\n cursor: default;\n}\n#tail_use_text {\n display: inline-block !important;\n background: #EEE;\n height: 30px;\n width: auto;\n padding: 0 10px;\n line-height: 30px !important;\n text-align: center !important;\n box-shadow: 0 0 3px #666;\n}\n#tail_use_box_out {\n position: absolute !important;\n width: 300px !important;\n}\n#tail_use_box {\n position: absolute !important;\n background: #EEE;\n bottom: 35px;\n left: 0;\n box-shadow: 0 0 3px #666;\n z-index: 100;\n}\n.tail_use_option {\n padding: 0 10px;\n line-height: 30px !important;\n}\n.tail_use_option:hover {\n background: #DDD;\n}"); +GM_addStyle("#setting_shadow {\n position: fixed;\n z-index: 1024000000;\n bottom: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.6);\n -moz-transition: 0.4s;\n}\n#setting_window {\n position: fixed;\n left: -moz-calc(50% - 320px);\n left: -webkit-calc(50% - 320px);\n width: 600px;\n background: #FFF;\n box-shadow: 0 0 5px #222;\n padding: 20px 20px 50px 20px;\n z-index: 1000000000;\n -moz-transition: 0.4s ease all;\n}\n#setting_out_div {\n overflow-y: scroll;\n padding: 0 10px 0 0;\n}\n.setting_btn_inside {\n font-size: 16px;\n padding: 4px;\n -moz-user-select: none;\n cursor: default;\n}\n.setting_btn_inside:hover {\n background: #DDD;\n}\n.setting_btn_inside:active {\n box-shadow: 0 0 3px #999 inset;\n}\n#setting_reset {\n position: absolute;\n top: 14px;\n right: 14px;\n}\n#setting_save {\n display: inline-block;\n position: absolute;\n right: 15px;\n bottom: 10px;\n}\n.setting_sp_btn {\n font-size: 12px;\n padding: 4px;\n -moz-user-select: none;\n cursor: default;\n display: inline-block;\n position: relative;\n}\n.setting_sp_btn.close {\n background: #DDD;\n}\n.setting_sp_btn::before {\n position: absolute;\n right: -26px;\n top: 0;\n content: \"\";\n width: 26px;\n height: 26px;\n background: #6B4;\n -moz-transition: 0.3s;\n}\n.setting_sp_btn.close::before {\n background: #C54;\n}\n.setting_sp_btn:hover {\n background: #DDD;\n}\n.setting_sp_btn:active {\n box-shadow: 0 0 3px #999 inset;\n}\n#setting_sp_q_c {\n margin: 0 0 0 40px !important;\n}\n#setting_window .setting_title {\n font-size: 34px;\n height: 42px;\n line-height: 42px;\n padding: 7px 10px;\n margin: 0 0 0 -7px;\n -moz-user-select: none;\n cursor: default;\n display: inline-block;\n}\n#setting_window p {\n font-size: 18px;\n height: 42px;\n line-height: 50px;\n -moz-user-select: none;\n cursor: default;\n}\n#setting_window p.setting_hide {\n height: 10px;\n line-height: 10px;\n -moz-user-select: none;\n cursor: default;\n}\n#setting_window p.setting_hide.sp {\n background: #CCC !important;\n height: 1px !important;\n margin: 8px 0 !important;\n}\n#setting_window p.setting_hiding_sp {\n height: 1px;\n line-height: 1px;\n -moz-user-select: none;\n cursor: default;\n}\n#setting_window .setting_input {\n -moz-appearance: none;\n border: none;\n background: #DDD;\n height: 28px;\n padding: 0px 7px !important;\n width: 100px;\n margin: 0 10px 0 0 !important;\n font-size: 14px !important;\n}\n#setting_window span {\n font-size: 14px !important;\n margin: 0 10px 0 0 !important;\n -moz-user-select: none;\n cursor: default;\n display: inline-block;\n}\n.setting_textarea {\n -moz-appearance: none !important;\n border: none;\n background: #DDD;\n margin: 10px 0 0 0 !important;\n padding: 7px !important;\n width: 550px;\n height: 100px;\n -moz-box-sizing: border-box;\n font-size: 12px !important;\n}\n#tail_select {\n display: inline-block;\n height: 26px !important;\n line-height: 26px !important;\n width: 450px !important;\n margin: 0px 0 0 40px !important;\n vertical-align: top !important;\n text-align: center !important;\n font-size: 12px !Important;\n -moz-box-sizing: border-box !Important;\n position: relative !important;\n cursor: default !important;\n}\n#tail_select_text {\n height: 26px;\n float: left;\n min-width: 100px !important;\n background: #DDD !important;\n padding: 0 5px !important;\n -moz-box-sizing: border-box !Important;\n}\n#tail_option_box {\n float: left;\n position: absolute !important;\n bottom: 30px;\n left: 0;\n min-width: 100px;\n background: #EEE !important;\n box-shadow: 0 0 3px #666 !important;\n display: inline-block;\n}\n.tail_option {\n padding: 0 8px !important;\n width: auto !important;\n font-size: 12px !important;\n height: 24px !important;\n line-height: 24px !important;\n cursor: default !important;\n}\n.tail_option:hover {\n background: #DDD !important;\n}\n#tail_type {\n background: #DDD !important;\n position: absolute !important;\n top: 0;\n right: 0px;\n}\n#tail_type_text {\n width: 80px !important;\n text-align: center !important;\n}\n#tail_type_box {\n position: absolute !important;\n width: 80px !important;\n bottom: 30px;\n right: 0px;\n background: #EEE;\n box-shadow: 0 0 3px #666;\n}\n.tail_type_option:hover {\n background: #DDD;\n}\n#tail_save {\n font-size: 12px !important;\n position: absolute;\n top: 0;\n right: 90px;\n height: 26px !important;\n padding: 0 !important;\n width: 86px !important;\n}\n#tail_new {\n font-size: 12px !important;\n -moz-box-sizing: border-box !Important;\n padding: 0 !important;\n height: 26px !important;\n width: 60px !important;\n position: absolute !important;\n top: 0 !important;\n right: 180px !important;\n}\n#tail_delete {\n font-size: 12px !important;\n -moz-box-sizing: border-box !Important;\n padding: 0 !important;\n height: 26px !important;\n width: 60px !important;\n position: absolute !important;\n top: 0 !important;\n right: 250px !important;\n}\n#tail_data + span {\n display: block !Important;\n margin: 5px 0 -3px 0 !important;\n font-size: 12px !Important;\n}\n#tail_use {\n margin-left: 20px;\n margin-right: 20px;\n height: 30px;\n width: auto;\n float: left !important;\n cursor: default;\n}\n#tail_use_text {\n width: auto;\n padding: 0 10px;\n line-height: 28px !important;\n text-align: center !important;\n}\n#tail_use_box_out {\n position: absolute !important;\n width: 300px !important;\n}\n#tail_use_box {\n position: absolute !important;\n background: #EEE;\n bottom: 35px;\n left: 0;\n box-shadow: 0 0 3px #666;\n z-index: 100;\n}\n.tail_use_option {\n padding: 0 10px;\n line-height: 30px !important;\n}\n.tail_use_option:hover {\n background: #DDD;\n}");