Last active
August 29, 2015 14:05
-
-
Save sumhat/41a09f2271bfc9f00f8b 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 myName = 'Sumhat'; | |
var myEmail = 'sumhat@gmail.com'; | |
var myUrl = 'http://leonax.net'; | |
function fillForm(blogIdSelector, authorSelector, urlSelector, emailSelector) { | |
if (blogIdSelector != null) { | |
var blogId = document.querySelector(blogIdSelector); | |
if (blogId == null) { | |
return false; | |
} | |
} | |
var author = document.querySelector(authorSelector); | |
if (author == null) { | |
return false; | |
} | |
author.setAttribute('value', myName); | |
var url = document.querySelector(urlSelector); | |
if (url != null) { | |
url.setAttribute('value', myUrl); | |
} | |
var email = document.querySelector(emailSelector); | |
if (email == null) { | |
return false; | |
} | |
email.setAttribute('value', myEmail); | |
return true; | |
} | |
var blogList = { | |
'wordpress': function() {return fillForm('#commentform', '#author', '#url', '#email');}, | |
'typecho': function() {return fillForm('#comment_form', '#author', '#url', '#mail');}, | |
'z_blog': function() {return fillForm('#frmSumbit', '#inpName', '#inpHomePage', '#inpEmail');}, | |
'emlog': function() {return fillForm('#commentform', 'input[name="comname"]', 'input[name="comurl"]', 'input[name="commail"]');} | |
}; | |
for (var i in blogList) { | |
if (blogList[i]()) { | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment