// ==UserScript== // @name tieba_emotion_helper // @namespace firefox // @include http://tieba.baidu.com/* // @description 贴吧自定义表情批量修改 // @version 1 // @grant GM_addStyle // @downloadURL https://update.greasyfork.icu/scripts/355/tieba_emotion_helper.user.js // @updateURL https://update.greasyfork.icu/scripts/355/tieba_emotion_helper.meta.js // ==/UserScript== var _window = typeof unsafeWindow == 'undefined' ? window: unsafeWindow; var $ = _window.$; var DEFAULT_EMOTION = '[{"title":"hhh",'+ '"url":"http://imgsrc.baidu.com/forum/pic/item/9345d688d43f8794045152ddd31b0ef41ad53a92.jpg",'+ '"thumbnail":"http://imgsrc.baidu.com/forum/abpic/item/9345d688d43f8794045152ddd31b0ef41ad53a92.jpg"},'+ '{"title":"hhh",'+ '"url":"http://imgsrc.baidu.com/forum/pic/item/9345d688d43f8794045152ddd31b0ef41ad53a92.jpg",'+ '"thumbnail":"http://imgsrc.baidu.com/forum/abpic/item/9345d688d43f8794045152ddd31b0ef41ad53a92.jpg"}]'; function loadText(){ var emotion = localStorage.customEmotion; if(emotion==undefined || emotion==null || emotion=="null"){ return DEFAULT_EMOTION; } if(emotion.indexOf("|")!=-1)emotion = emotion.substring(emotion.indexOf("|") + 1,emotion.length); return emotion; } function save(){ var data = $("#add_emotion_text").attr("value"); if(data!=""){ try{ JSON.parse(data); }catch(e){ alert("填写格式错误");return; } var d = new Date(); d.setFullYear(d.getFullYear()+1); localStorage.customEmotion = d.getTime() +"|"+ data; }else{ localStorage.customEmotion = undefined; } $('.s_tab_btn[data-type="custom"]').click(); close(); } function close(){ $(".dialogJshadow").remove(); } function a(){ if($(".j_add_emotion").length){ $(".j_add_emotion").removeClass("j_add_emotion").addClass("custom_add_emotion").html("修改"); $(".custom_add_emotion").click(function(){ var dialog = '
\
\
\ 批量插入自定义表情\  \
\
\
\
\
\

属性介绍:

\ title : 表情描述\ url : 表情地址\ thumbnail : 表情缩略图地址\ \
\
\ \
\
\
\
\
'; $("body").append(dialog); $(".dialogJclose").click(close); $("#add_emotion_text").html(loadText()).attr("value",loadText()); $(".i_layer_bottom .i_layer_btn").click(save); $(".i_layer_bottom .ui_btn_sub_m").click(close); }) }else{ setTimeout(a,100); } } (function _init(){ if($('.edui-btn.edui-btn-emotion').length){ $('.edui-btn.edui-btn-emotion').click(a); } else{ setTimeout(_init,100); } })();