From d817179747bbd3cb7a5cc7e3c8ab6a82384d7494 Mon Sep 17 00:00:00 2001 From: Ruud Date: Fri, 24 Aug 2012 22:46:32 +0200 Subject: [PATCH] De-referer external urls. --- couchpotato/core/plugins/movie/static/movie.js | 11 +---------- couchpotato/static/scripts/couchpotato.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/couchpotato/core/plugins/movie/static/movie.js b/couchpotato/core/plugins/movie/static/movie.js index 2182b887..dbb28aa5 100644 --- a/couchpotato/core/plugins/movie/static/movie.js +++ b/couchpotato/core/plugins/movie/static/movie.js @@ -323,19 +323,10 @@ var IMDBAction = new Class({ self.el = new Element('a.imdb', { 'title': 'Go to the IMDB page of ' + self.movie.getTitle(), - 'events': { - 'click': self.gotoIMDB.bind(self) - } + 'href': 'http://www.imdb.com/title/'+self.id+'/' }); if(!self.id) self.disable(); - }, - - gotoIMDB: function(e){ - var self = this; - (e).preventDefault(); - - window.open('http://www.imdb.com/title/'+self.id+'/'); } }); diff --git a/couchpotato/static/scripts/couchpotato.js b/couchpotato/static/scripts/couchpotato.js index b99e6c7e..9e66e342 100644 --- a/couchpotato/static/scripts/couchpotato.js +++ b/couchpotato/static/scripts/couchpotato.js @@ -29,6 +29,7 @@ var CouchPotato = new Class({ History.addEvent('change', self.openPage.bind(self)); self.c.addEvent('click:relay(a[href^=/]:not([target]))', self.pushState.bind(self)); + self.c.addEvent('click:relay(a[href^=http])', self.openDerefered.bind(self)); }, getOption: function(name){ @@ -269,6 +270,17 @@ var CouchPotato = new Class({ createUrl: function(action, params){ return this.options.base_url + (action ? action+'/' : '') + (params ? '?'+Object.toQueryString(params) : '') + }, + + openDerefered: function(e, el){ + (e).stop(); + + var url = 'http://www.dereferer.org/?' + el.get('href'); + + if(el.get('target') == '_blank' || (e.meta && Browser.Platform.mac) || (e.control && !Browser.Platform.mac)) + window.open(url); + else + window.location = url; } });