Skip to content

Commit

Permalink
Fix for #80.
Browse files Browse the repository at this point in the history
  • Loading branch information
june07 committed May 21, 2020
1 parent f6d833a commit 4d1ef3e
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -660,9 +660,11 @@ ngApp
responseType: "json"
})
.then(function openDevToolsFrontend(json) {
if (!json.data[0].devtoolsFrontendUrl) return callback(chrome.i18n.getMessage("errMsg7", [host, port]));
setDevToolsURL(json.data[0]);
var url = json.data[0].devtoolsFrontendUrl.replace(/ws=localhost/, 'ws=127.0.0.1');
let jsonPayload = browserAgnosticFix(json.data[0]);
if (!jsonPayload.devtoolsFrontendUrl) return callback(chrome.i18n.getMessage("errMsg7", [host, port]));

setDevToolsURL(jsonPayload);
var url = jsonPayload.devtoolsFrontendUrl.replace(/ws=localhost/, 'ws=127.0.0.1');
var inspectIP = url.match(SOCKET_PATTERN)[1];
var inspectPORT = url.match(SOCKET_PATTERN)[5];
url = url
Expand All @@ -674,19 +676,19 @@ ngApp
}
if ($scope.settings.bugfix)
url = url.replace('', '');
var websocketId = json.data[0].id;
var websocketId = jsonPayload.id;
/** May be a good idea to put this somewhere further along the chain in case tab/window creation fails,
in which case this entry will need to be removed from the array */
// The following analytics setting is TOO verbose.
//$window._gaq.push(['_trackEvent', 'Program Event', 'openTab', 'Non-existing tab.', undefined, true]);
if (tab.length === 0) {
createTabOrWindow(infoUrl, url, websocketId, json.data[0])
createTabOrWindow(infoUrl, url, websocketId, jsonPayload)
.then(function(tab) {
var tabToUpdate = tab;
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo) {
if (triggerTabUpdate && tabId === tabToUpdate.id && changeInfo.status === 'complete') {
triggerTabUpdate = false;
saveSession(url, infoUrl, websocketId, tabToUpdate.id, json.data[0]);
saveSession(url, infoUrl, websocketId, tabToUpdate.id, jsonPayload);
callback(tabToUpdate.url);
} else if (!triggerTabUpdate && tabId === tabToUpdate.id) {
if ($scope.settings.debugVerbosity >= 6) console.log('Loading updated tab [' + tabId + ']...');
Expand Down Expand Up @@ -983,7 +985,7 @@ ngApp
responseType: "json"
})
.then(function openDevToolsFrontend(json) {
return json.data[0].id;
return browserAgnosticFix(json.data[0]).id;
})
.catch(function(error) {
return error;
Expand Down Expand Up @@ -1560,6 +1562,11 @@ ngApp
if ($scope.settings.debugVerbosity >= 4) console.log(notificationId);
});
}
function browserAgnosticFix(jsonPayload) {
if (jsonPayload && jsonPayload.devtoolsFrontendUrlCompat) jsonPayload.devtoolsFrontendUrl = jsonPayload.devtoolsFrontendUrl.replace(/chrome-devtools:\/\//, 'devtools://');
if (jsonPayload && jsonPayload.devtoolsFrontendUrlCompat) jsonPayload.devtoolsFrontendUrlCompat = jsonPayload.devtoolsFrontendUrlCompat.replace(/chrome-devtools:\/\//, 'devtools://');
return jsonPayload;
}
chrome.notifications.onClicked.addListener(function onClickedHandler(notificationId) {
let notification = $scope.notificationService.getNotification(notificationId);
switch (notification.type) {
Expand Down

0 comments on commit 4d1ef3e

Please sign in to comment.