From c61876c9a5fa3fd92e77546a44300a07e8e06d78 Mon Sep 17 00:00:00 2001 From: Jonathan Cremin Date: Sun, 11 Jan 2015 16:42:12 +0000 Subject: [PATCH] Fix Chrome extension search results parsing --- chrome/background.js | 7 +++---- chrome/manifest.json | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/chrome/background.js b/chrome/background.js index 88d5f8f..c95a76c 100644 --- a/chrome/background.js +++ b/chrome/background.js @@ -41,10 +41,9 @@ chrome.pageAction.onClicked.addListener(function(tab) { xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState == 4) { - var parser = document.createElement('a'); - parser.href = xhr.responseURL; - if (!parser.pathname.match(/^(\/search|\/)$/)) { - chrome.tabs.create({ url: xhr.responseURL}); + var match = JSON.parse(xhr.response); + if (match.id) { + chrome.tabs.create({ url: "https://match.audio/" + match.service + "/" + match.type + "/" + match.id}); } } } diff --git a/chrome/manifest.json b/chrome/manifest.json index 7d5148c..374122a 100644 --- a/chrome/manifest.json +++ b/chrome/manifest.json @@ -1,6 +1,6 @@ { "name" : "Match Audio", - "version" : "0.2.0", + "version" : "0.2.1", "description" : "Match Audio makes sharing from music services better.", "background" : { "persistent": false,