diff --git a/couchpotato/core/plugins/userscript/main.py b/couchpotato/core/plugins/userscript/main.py index bddd56a5..4ca8ed37 100644 --- a/couchpotato/core/plugins/userscript/main.py +++ b/couchpotato/core/plugins/userscript/main.py @@ -15,7 +15,7 @@ log = CPLog(__name__) class Userscript(Plugin): - version = 4 + version = 5 def __init__(self): addApiView('userscript.get/(.*)/(.*)', self.getUserScript, static = True) diff --git a/couchpotato/core/plugins/userscript/template.js_tmpl b/couchpotato/core/plugins/userscript/template.js_tmpl index 202f5dc6..5a32da39 100644 --- a/couchpotato/core/plugins/userscript/template.js_tmpl +++ b/couchpotato/core/plugins/userscript/template.js_tmpl @@ -25,13 +25,16 @@ var version = {{version}}, host = '{{host}}', api = '{{api}}'; -function create() { +var create = function() { + var A, B; switch (arguments.length) { case 1: - var A = document.createTextNode(arguments[0]); + A = document.createTextNode(arguments[0]); break; default: - var A = document.createElement(arguments[0]), B = arguments[1]; + A = document.createElement(arguments[0]); + B = arguments[1]; + for ( var b in B) { if (b.indexOf("on") == 0){ A.addEventListener(b.substring(2), B[b], false);