1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | /************************************ * 噗浪表符計數器(書籤版) * * 用法: * 1. 將下段javascript儲存成書籤 * 2. 進入噗浪,先打開表符清單 * 3. 點擊剛才弄好的書籤 * 4. 點擊表符組別的圖示,即可在右上角看見表符的組別數量/總數 * ************************************/ javascript:(function(){ function getEmoTotalCount(){ var total = 0; for (let grp of EmoticonCustom.getGroups()){ total += EmoticonCustom.getEmoticons(grp.id).length; } return total; } function addEmoCounterNode(){ var newNode = document.createElement("DIV"); newNode.id = "emoCounter"; var postNode = document.querySelector('#emoticon-selector-holder .manager-button'); postNode.parentNode.insertBefore(newNode, postNode); $(newNode).css({ position : "absolute", right: "50px", top: "12px", lineHeight: "26px" }); return newNode; } function updateEmoCounterNode(groupType, groupId){ var counterNode = document.querySelector('#emoCounter'); if (counterNode == undefined){ counterNode = addEmoCounterNode(); } var html = ''; if (groupType == 'custom'){ html = EmoticonCustom.getEmoticons(groupId).length + '/' + getEmoTotalCount(); } else{ html = getEmoTotalCount(); } $(counterNode).html(html); } $('#emoticon-tabs li[emo-group-type]').on( "click", function() { let grpType = $(this).attr('emo-group-type'); let grpId = $(this).attr('emo-group-id'); updateEmoCounterNode(grpType, grpId); }); })() |
Direct link: https://paste.plurk.com/show/umyGNo5ScNqEwnlEjr1N