18/09/25 23:30:41.93 DATT+Aw90.net
>>775
選択した文字列をドラッグしたら動くはず
それともドラッグして選択した時点で放り込みたいという話?
だとしたらこんな感じ
(function(){
window.messageManager.addMessageListener('select_text', function listener(message){
const searchbar = document.getElementById('searchbar');
let text = message.data? message.data : '';
text? searchbar.textbox.value = text : null;
});
function contentScript(){
function send_select_text(e){
const doc = e.originalTarget;
doc.onselectionchange = function() {sendAsyncMessage('select_text', doc.getSelection().toString())};
}
addEventListener('DOMContentLoaded', send_select_text, false);
}
let src = contentScript.toString();
let script = 'data:application/javascript;charset=utf-8,' + encodeURIComponent('(' + src + ')();');
window.messageManager.loadFrameScript(script, true);
contentScript = null;
})()