From 7dd89247f2e244d4ae1b4f1b3f015de4f522ec9b Mon Sep 17 00:00:00 2001 From: Ruud Date: Sun, 18 Mar 2012 17:44:20 +0100 Subject: [PATCH] Post hostname with bookmark --- couchpotato/core/plugins/userscript/bookmark.js | 2 +- couchpotato/core/plugins/userscript/main.py | 2 +- couchpotato/core/plugins/userscript/static/userscript.js | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/couchpotato/core/plugins/userscript/bookmark.js b/couchpotato/core/plugins/userscript/bookmark.js index 3e0e517a..5ee8c376 100644 --- a/couchpotato/core/plugins/userscript/bookmark.js +++ b/couchpotato/core/plugins/userscript/bookmark.js @@ -34,7 +34,7 @@ var addUserscript = function() { var e = document.createElement('script'); e.setAttribute('type', 'text/javascript'); e.setAttribute('charset', 'UTF-8'); - e.setAttribute('src', '{{host}}/userscript.get/couchpotato.js?r=' + Math.random() * 99999999); + e.setAttribute('src', '{{host}}couchpotato.js?r=' + Math.random() * 99999999); document.body.appendChild(e) } if(isCorrectUrl()) diff --git a/couchpotato/core/plugins/userscript/main.py b/couchpotato/core/plugins/userscript/main.py index 1f9c0eb0..160d85ab 100644 --- a/couchpotato/core/plugins/userscript/main.py +++ b/couchpotato/core/plugins/userscript/main.py @@ -31,7 +31,7 @@ class Userscript(Plugin): params = { 'includes': fireEvent('userscript.get_includes', merge = True), 'excludes': fireEvent('userscript.get_excludes', merge = True), - 'host': fireEvent('app.api_url', single = True) + 'host': getParam('host', None), } return self.renderTemplate(__file__, 'bookmark.js', **params) diff --git a/couchpotato/core/plugins/userscript/static/userscript.js b/couchpotato/core/plugins/userscript/static/userscript.js index bdf0f27c..21edc636 100644 --- a/couchpotato/core/plugins/userscript/static/userscript.js +++ b/couchpotato/core/plugins/userscript/static/userscript.js @@ -72,6 +72,8 @@ var UserscriptSettingTab = new Class({ catch(e){ userscript = Browser.chrome === true; } + + var host_url = window.location.protocol + '//' + window.location.host; self.settings.createGroup({ 'name': 'userscript', @@ -87,8 +89,9 @@ var UserscriptSettingTab = new Class({ new Element('a.button.green', { 'text': '+CouchPotato', 'href': "javascript:void((function(){var e=document.createElement('script');e.setAttribute('type','text/javascript');e.setAttribute('charset','UTF-8');e.setAttribute('src','" + - window.location.protocol + '//' + window.location.host + Api.createUrl('userscript.bookmark') + - "?r='+Math.random()*99999999);document.body.appendChild(e)})());", + host_url + Api.createUrl('userscript.bookmark') + + "?host="+ encodeURI(host_url + Api.createUrl('userscript.get')) + + "&r='+Math.random()*99999999);document.body.appendChild(e)})());", 'target': '', 'events': { 'click': function(e){