Last active
March 6, 2018 05:16
-
-
Save tesiyosi/f5668fbf8b35f83190ab313b271873a8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var out = "javascript:function sC(n,v,c){var elms=document.getElementsByTagName('input');for(ind in elms){o=elms[ind];if(o.name==n && o.value==v){o.checked=c;}}}function sI(n,v,c){var elms=document.getElementsByTagName('input');for(ind in elms){o=elms[ind];if(o.name==n){o.value=v;o.checked=c;}}}function sO(v){var elms=document.getElementsByTagName('option');for(ind in elms){o=elms[ind];if(o.value==v){o.selected='selected'}}}function sT(n,v){var elms=document.getElementsByTagName('textarea');for(ind in elms){o=elms[ind];if(o.name==n){o.value=v;}}}"; | |
var elms, ind, o; | |
elms = document.getElementsByTagName('input'); | |
for (ind in elms) { | |
o = elms[ind]; | |
if (o.type == "hidden") { | |
continue; | |
} else if ((o.type == "checkbox" || o.type == "radio") && o.name && o.value) { | |
out += "sC('" + o.name + "','" + encodeURIComponent(o.value) + "'," + o.checked + ");"; | |
} else if (o.name && o.value) { | |
out += "sI('" + o.name + "','" + encodeURIComponent(o.value) + "');" | |
} | |
} | |
elms = document.getElementsByTagName('option'); | |
for (ind in elms) { | |
o = elms[ind]; | |
if (o.selected) { | |
out += "sO('" + o.value + "');" | |
} | |
} | |
elms = document.getElementsByTagName('textarea'); | |
for (ind in elms) { | |
o = elms[ind]; | |
if (o.value) { | |
out += "sT('" + o.name + "','" + encodeURIComponent(o.value.replace(/\s+/g, ' ')) + "');" | |
} | |
} | |
out += "void(0);"; | |
console.log(out); | |
var a = document.createElement('a'); | |
a.href = out; | |
a.textContent = 'フォーム自動入力'; | |
a.style.display = 'block'; | |
a.style.position = 'fixed'; | |
a.style.backgroundColor = '#eee'; | |
a.style.padding = "40px"; | |
a.style.top = "100px"; | |
a.style.left = "100px"; | |
a.style.zIndex = 1000; | |
a.style.border = "1px solid black"; | |
document.body.appendChild(a); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment