Skip to content
Permalink
Browse files

Moved localDevTOolsOptions from settings as it is not really neccessa…

…ry. Just pointed to the index in settings with `localDevToolsOptionsSelectedIndex`. Added devToolsCompat setting and made default as most recent version of Chrome seems to have the missing file browser again. Updated settings minification to add new untracked values. Chaned VSCode info link to open into _blank from options page.
  • Loading branch information...
june07 committed May 23, 2019
1 parent 84f1a9d commit 21b306463e927879db99efbab1357e5f29b310bf
Showing with 65 additions and 32 deletions.
  1. +46 −21 background.js
  2. +4 −0 css/nim.css
  3. +12 −7 options.html
  4. +1 −4 options.js
  5. +2 −0 package.json
@@ -65,14 +65,6 @@ ngApp
$scope.timerUptime = 0;
$scope.timerNotification = 0;
$scope.VERSION = VERSION;
$scope.settingsRevised = {
localDevToolsOptions: [
{ 'id': '0', 'name': 'default', 'url': '', 'selected': true },
{ 'id': '1', 'name': 'appspot', 'url': 'https://chrome-devtools-frontend.appspot.com/serve_file/@548c459fb7741b83bd517b12882f533b04a5513e/inspector.html' },
{ 'id': '2', 'name': 'june07', 'url': 'https://chrome-devtools-frontend.june07.com/front_end/inspector.html' },
{ 'id': '3', 'name': 'custom', 'url': '' },
]
};
$scope.settings = {
DEVEL: DEVEL,
host: "localhost",
@@ -95,12 +87,23 @@ ngApp
chromeNotifications: true,
autoIncrement: {type: 'port', name: 'Port'}, // both | host | port | false
collaboration: false,
localDevToolsOptions: $scope.settingsRevised.localDevToolsOptions,
panelWindowType: false,
nimsVscode: {
enabled: true
}
},
devToolsCompat: true,
localDevToolsOptionsSelectedIndex: 0
};
$scope.localDevToolsOptions = [
/* The url is set as a default to prevent a nasty case where an unset value results in an undefined which further results in runaway tabs opening.
* Decided to use the devtoolsFrontendUrlCompat url as currently it's the one that works more fully (see https://blog.june07.com/missing/)
* Todo: write a failsafe to prevent that condition too!
*/
{ 'id': '0', 'name': 'default', 'url': 'chrome-devtools://devtools/bundled/inspector.html', 'selected': true },
{ 'id': '1', 'name': 'appspot', 'url': 'https://chrome-devtools-frontend.appspot.com/serve_file/@548c459fb7741b83bd517b12882f533b04a5513e/inspector.html' },
{ 'id': '2', 'name': 'june07', 'url': 'https://chrome-devtools-frontend.june07.com/front_end/inspector.html' },
{ 'id': '3', 'name': 'custom', 'url': '' },
];
$scope.remoteTabs = [];
$scope.localSessions = [];
$scope.state = {
@@ -116,15 +119,15 @@ ngApp
$scope.locks = [];
$scope.moment = $window.moment;
$scope.getDevToolsOption = function() {
return $scope.settings.localDevToolsOptions.find((option) => {
return $scope.localDevToolsOptions.find((option) => {
return option.selected;
});
};
$scope.validateCustomDevToolsURL = function() {
if ($scope.settings.localDevToolsOptions[3].url === undefined)
$scope.settings.localDevToolsOptions[3].url = $scope.settings.localDevToolsOptions[1].url;
else if (!$scope.settings.localDevToolsOptions[3].url.match(devToolsURL_Regex))
$scope.settings.localDevToolsOptions[3].url = $scope.settings.localDevToolsOptions[1].url;
if ($scope.localDevToolsOptions[3].url === undefined)
$scope.localDevToolsOptions[3].url = $scope.localDevToolsOptions[1].url;
else if (!$scope.localDevToolsOptions[3].url.match(devToolsURL_Regex))
$scope.localDevToolsOptions[3].url = $scope.localDevToolsOptions[1].url;
}

let tabId_HostPort_LookupTable = [],
@@ -256,14 +259,14 @@ ngApp
})
.then(function openDevToolsFrontend(json) {
if (!json.data[0].devtoolsFrontendUrl) return callback(chrome.i18n.getMessage("errMsg7", [host, port]));
$scope.settings.localDevToolsOptions[0].url = json.data[0].devtoolsFrontendUrl.split('?')[0];
setDevToolsURL(json.data[0]);
var url = json.data[0].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
.replace(inspectIP + ":9229", host + ":" + port) // In the event that remote debugging is being used and the infoUrl port (by default 80) is not forwarded take a chance and pick the default.
.replace(inspectIP + ":" + inspectPORT, host + ":" + port) // A check for just the port change must be made.
if ($scope.settings.localDevTools)
if ($scope.settings.localDevTools || $scope.settings.devToolsCompat)
url = url.replace(devToolsURL_Regex, $scope.getDevToolsOption().url);
if ($scope.settings.bugfix)
url = url.replace('', '');
@@ -399,10 +402,23 @@ ngApp
}
})
}
$scope.setDevToolsOption = function(optionIndex) {
$scope.localDevToolsOptions.forEach((option, i) => {
if (i === optionIndex) {
option.selected = true;
$scope.settings.localDevToolsOptionsSelectedIndex = optionIndex;
} else {
option.selected = false;
}
});
};
function setDevToolsURL(nodeJSONMeta) {
$scope.localDevToolsOptions[0].url = ($scope.settings.devToolsCompat) ? nodeJSONMeta.devtoolsFrontendUrlCompat.split('?')[0] : nodeJSONMeta.devtoolsFrontendUrl.split('?')[0];
}
function getDevToolsURL(session) {
let url = session.devtoolsFrontendUrl;
// The following line is required because normally the host part of the URL is set dynamically in `function openDevToolsFrontend(json)`
if ($scope.getDevToolsOption() === '') $scope.settings.localDevToolsOptions[0].url = url.split('?')[0];
if ($scope.getDevToolsOption() === 'chrome-devtools://devtools/bundled/inspector.html') $scope.localDevToolsOptions[0].url = url.split('?')[0];
if ($scope.settings.localDevTools) url = url.replace(devToolsURL_Regex, $scope.getDevToolsOption().url);
return url;
}
@@ -926,8 +942,9 @@ ngApp
if ($scope.settings.debugVerbosity >= 1) console.log('Restoring saved settings.');
chrome.storage.sync.get(function(sync) {
var keys = Object.keys(sync);
keys.forEach(function(key) {
keys.forEach(function(key, i, keys) {
$scope.settings[key] = sync[key];
if (i === keys.length-1) $scope.setDevToolsOption($scope.settings.localDevToolsOptionsSelectedIndex);
});
});
}
@@ -937,7 +954,6 @@ ngApp
}
}
function updateSettings() {
write('localDevToolsOptions', $scope.settingsRevised.localDevToolsOptions);
}
function saveAll() {
saveAllToChromeStorage($scope.settings, 'settings');
@@ -982,8 +998,17 @@ ngApp
case 'collaboration': entry[0] = 'c'; break;
case 'loginRefreshInterval': entry[0] = 'lri'; break;
case 'tokenRefreshInterval': entry[0] = 'tri'; break;
case 'remoteProbeInterval': entry[0] = 'r'; break;
case 'localSessionTimeout': entry[0] = 'l'; break;
case 'panelWindowType': entry[0] = 'pa'; break;
case 'nimsVscode': entry[0] = 'n'; break;
case 'devToolsCompat': entry[0] = 'd'; break;
case 'localDevToolsOptionsSelectedIndex': entry[0] = 'ld'; break;
}
if (index === tinySettings.length-1) {
tinySettings.splice(tinySettings.findIndex(e => e[0] === 'DEVEL'), 1);
callback(JSON.stringify(tinySettings));
}
if (index === tinySettings.length-1) callback(JSON.stringify(tinySettings));
});
}
function formatParams() {
@@ -692,3 +692,7 @@ input:not([type]):focus:not([readonly]), input[type=text]:not(.browser-default):
-webkit-box-shadow: 0 1px 0 0 #4CAF50;
box-shadow: 0 1px 0 0 #4CAF50;
}
span#devToolsCompat {
float: right;
margin-right: 50px;
}
@@ -98,18 +98,23 @@
<span class="lever"></span><span class="i18n">on</span>
</label>
</div>
<div ng-if="!bg.settings.localDevTools">
<div ng-hide="bg.settings.localDevTools">
<span>{{ window.chrome.i18n.getMessage("defaultDevTools") }}</span>

<span id="devToolsCompat">
<input type="checkbox" id="devToolsCompatCheckbox" ng-model="bg.settings.devToolsCompat" />
<label for="devToolsCompatCheckbox">DevToolsCompat</label>
</span>
<span id="devToolsBadge">DevTools Version ({{ bg.getDevToolsOption().name }}): <span id="devToolsBadgeLabel" class="badge">{{ bg.getDevToolsOption().url }}</span></span>
</div>
<a ng-hide="!bg.settings.localDevTools" class="dropdown-button" href="#" data-activates="dropdown1">
<span id="selectDevToolsVersion">{{ window.chrome.i18n.getMessage("selectDevToolsVersion") }}</span>
<span id="devToolsBadge">DevTools Version ({{ bg.getDevToolsOption().name }}): <span id="devToolsBadgeLabel" class="badge">{{ bg.getDevToolsOption().url }}</span></span>
<span id="devToolsBadge">DevTools Version ({{ bg.getDevToolsOption().name }}): <span id="devToolsBadgeLabel" class="badge">{{ bg.getDevToolsOption().url }}</span></span>
</a>
<ul id="dropdown1" class="dropdown-content">
<li><a href="#!" ng-click="setDevToolsOption(1)">{{ bg.settings.localDevToolsOptions[1].name }}: {{ bg.settings.localDevToolsOptions[1].url }} </a></li>
<li><a href="#!" ng-click="setDevToolsOption(2)">{{ bg.settings.localDevToolsOptions[2].name }}: {{ bg.settings.localDevToolsOptions[2].url }} </a></li>
<li><a href="#modal3" ng-click="setDevToolsOption(3)" class="modal-trigger">{{ bg.settings.localDevToolsOptions[3].name }}: {{ bg.settings.localDevToolsOptions[3].url }}</a></li>
<li><a href="#!" ng-click="setDevToolsOption(1)">{{ bg.localDevToolsOptions[1].name }}: {{ bg.localDevToolsOptions[1].url }} </a></li>
<li><a href="#!" ng-click="setDevToolsOption(2)">{{ bg.localDevToolsOptions[2].name }}: {{ bg.localDevToolsOptions[2].url }} </a></li>
<li><a href="#modal3" ng-click="setDevToolsOption(3)" class="modal-trigger">{{ bg.localDevToolsOptions[3].name }}: {{ bg.localDevToolsOptions[3].url }}</a></li>
</ul>
</li>
<li class="collection-item">
@@ -128,7 +133,7 @@
<span class="lever"></span><span class="i18n">on</span>
</label>
</div>
<a href="https://bit.ly/2VwKeSZ" class="modal-trigger"><span class="i18n">optionsNiMSVSCode</span></a>
<a href="https://bit.ly/2VwKeSZ" target="_blank" class="modal-trigger"><span class="i18n">optionsNiMSVSCode</span></a>
</li>
<li class="collection-item bottom">
<span class="i18n">secondsBetweenInspectorChecks</span>
@@ -185,7 +190,7 @@
<ul class="collection with-header">
<li class="collection-header" id="collections-header-customDevToolsURL"><span class="i18n">optionsCustomDevToolsURL</span></li>
<li class="collection-item">
<input placeholder="" ng-model="bg.settings.localDevToolsOptions[3].url" id="devtools_url" type="url" class="validate" pattern="(chrome-devtools:\/\/|https:\/\/chrome-devtools-frontend(.appspot.com|.june07.com)).*(inspector.html|js_app.html)" ng-pattern="/(chrome-devtools:\/\/|https:\/\/chrome-devtools-frontend(.appspot.com|.june07.com)).*(inspector.html|js_app.html)/">
<input placeholder="" ng-model="bg.localDevToolsOptions[3].url" id="devtools_url" type="url" class="validate" pattern="(chrome-devtools:\/\/|https:\/\/chrome-devtools-frontend(.appspot.com|.june07.com)).*(inspector.html|js_app.html)" ng-pattern="/(chrome-devtools:\/\/|https:\/\/chrome-devtools-frontend(.appspot.com|.june07.com)).*(inspector.html|js_app.html)/">
<label for="devtools_url">DevTools URL <span id="nim-custom-devtools-url-blogpost"><a href="https://june07.com/blog/nim-custom-devtools-url" target="_blank">(Not sure what to put here...)</a></span></label>
<div><a class="btn green" id="save-button-custom-devtools" value="Save Custom DevTools" ng-click="saveCustomDevToolsButtonHandler()"><span class="i18n">save</span></a></div>
</li>
@@ -99,10 +99,7 @@ ngApp
$('#modal3').modal('close');
}
$scope.setDevToolsOption = function(optionIndex) {
$scope.bg.settings.localDevToolsOptions.forEach((option, i) => {
if (i === optionIndex) option.selected = true;
else option.selected = false;
});
$scope.bg.setDevToolsOption(optionIndex);
};
$scope.resetDevToolsOption = function() {
if (!$scope.bg.settings.localDevTools) $scope.setDevToolsOption(0);
@@ -12,6 +12,7 @@
"bootstrap": "^4.1.0",
"bootstrap-notify": "*",
"jquery": "*",
"jsoncomp": "^1.6.1",
"jsrsasign": "^8.0.12",
"jssha": "^2.3.1",
"materialize-css": "^0.100.2",
@@ -20,6 +21,7 @@
"perfect-scrollbar": "^0.8.1",
"popper.js": "^1.15.0",
"tippy.js": "^4.3.1",
"tweetnacl": "^1.0.1",
"tweetnacl-util": "^0.15.0",
"wnumb": "*"
},

0 comments on commit 21b3064

Please sign in to comment.
You can’t perform that action at this time.