Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
javascript:document.addEventListener('paste', function(event){
var obj = event.target;
if (!(obj instanceof HTMLTextAreaElement)) return;
var firstText = obj.value.substr(0, obj.selectionStart);
var latterText = obj.value.substr(obj.selectionEnd);
obj.addEventListener('input', function(evt){
evt.currentTarget.removeEventListener(evt.type, arguments.callee, false);
var pastedText = obj.value.substring(firstText.length, obj.value.length - latterText.length);
pastedText = pastedText.replace(/javascript:/g, '');
obj.value = firstText + pastedText + latterText;
}, false);
},false)
/*
ペースト時に「ペーストされた部分」のみ特定の文字を置き換えるスクリプト。
setTimeout を使わないのは気分
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.