fix unnecessary alias naming of variable |doReplace|
combine optional parameters in one
improve URL security checker

* check a trusted URL with |nsIScriptSecurityManager.STANDARD| flag
* add a flag to trust the data URI of image
define import functions at the top of file