import * as log from "./log" ; import * as operations from "./operations" ; import * as stylesheets from "./stylesheets" ; export function run ( userscript ) { log . setPrefix ( `[${ userscript . name }]` ) ; const attr = attribute ( userscript . id ) ; if ( document . documentElement . hasAttribute ( attr ) ) { log . warning ( `It looks as though ${ userscript . name } has already run (because the attribute "${ attr }" was found on <head>). Stopping.` ) ; } else { document . documentElement . setAttribute ( attr , "" ) ; userscript . initialAction ( ) ; stylesheets . insert ( userscript . stylesheets ) ; operations . run ( userscript . operationsPlan ) ; } } function attribute ( id ) { return "data-" + id + "-has-run" ; }