diff --git a/chrome/background.js b/chrome/background.js index fbe57cf..8dbb3ab 100644 --- a/chrome/background.js +++ b/chrome/background.js @@ -80,23 +80,26 @@ function getServers() { * @return Object */ function getBackend(request) { - var routes = getRoutes(); + var matches = [], + routes = getRoutes(); + for (var i = 0; i < routes.length; i++) { var route = routes[i]; if (!route.match.test(request.url)) { continue; } var servers = getServers(); - for (i = 0; i < servers.length; i++) { - if (servers[i].id === route.id) { - return { - serverURL: servers[i].url, + for (var j = 0; j < servers.length; j++) { + if (servers[j].id === route.id) { + matches.push({ + serverURL: servers[j].url, savePath: urlToPath(request.url.replace(route.match, route.savePath)) - }; + }); } } } - return null; + + return (matches.length === 0 ? null : {matches: matches}); } /** diff --git a/chrome/devtools.js b/chrome/devtools.js index c2ca052..e6117f8 100644 --- a/chrome/devtools.js +++ b/chrome/devtools.js @@ -80,6 +80,7 @@ chrome.devtools.inspectedWindow.onResourceContentCommitted.addListener(function( function sendToBackgroundPage() { var patch; + if (isNewlyAdded(event)) { console.info('New CSS rules added. Appending them to', lastStylesheetURL); var oldAddedCSS = addedCSS; @@ -99,17 +100,25 @@ chrome.devtools.inspectedWindow.onResourceContentCommitted.addListener(function( return; } - chrome.extension.sendRequest({ - method: 'send', - content: JSON.stringify(patch), - url: response.serverURL, - headers: { - 'Content-Type': 'application/json', - 'X-URL': url, - 'X-Path': response.savePath, - 'X-Type': event.type - } - }); + if(!response.matches) { + response.matches = []; + response.matches.push(response); + } + + for (var i=0; i