Optimize exec logic.

This commit is contained in:
Kenshin 2018-06-22 14:30:55 +08:00
parent 90d00fe4e7
commit 048eac24bd

View File

@ -39,10 +39,15 @@ function install( id, url, callback ) {
/**
* Execute
*
* @param {string} state, include: read_start, read_loading, read_complete, read_end
* @param {string} site name, inlcude: "", "xxx", "xxx, yyy"
* @param {object} plugin object
*/
function exec( plugin ) {
function exec( state, site, plugin ) {
if ( plugin.enable == false ) return;
if ( plugin.run_at != state ) return;
if ( plugin.site != "" && !plugin.site.split(",").includes( site ) ) return;
console.log( "current plugin is running", plugin )
new Function( func( plugin.script ) )();
plugin.style != "" && addStyle( plugin.style );
}