1 | javascript:(function() { if (!(window.File || window.FileReader || window.FileList || window.Blob)) { alert('瀏覽器不支援讀取檔案功能,請換瀏覽器'); return; } if($('#emoticon-selector').css('display') != 'block') { alert('未開啟表符欄'); return; } let emo_group_id = $('#emoticon-tabs .current').attr('emo-group-id'); if(typeof(emo_group_id) == 'undefined') { alert('只能上傳到自訂表符分頁'); return; } let emo_upload = $('<input type="file"/>'); emo_upload.change(() => { let reader = new FileReader(); reader.readAsText(emo_upload.prop('files')[0], "UTF-8"); reader.onload = async function() { let fileString = JSON.parse(this.result); let err = false; for(let emoemo of fileString) { if(err) break; await EmoticonCustom.addEmoticon(emoemo.u, emoemo.k, emo_group_id) .fail(()=>{ if(!err) alert('表符已滿'); err = true; }); } } }); emo_upload.click(); })() |
Direct link: https://paste.plurk.com/show/a7z1AjsZ3Z4P7SM5yaai