Skip to content

Commit d0ccf1b

Browse files
committed
fix init storage - support chrome modern
1 parent 54302e0 commit d0ccf1b

4 files changed

Lines changed: 8 additions & 12 deletions

File tree

bin/createConfig.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const fs = require('fs');
2+
const version = require('../package.json').version;
23

34
const config = require(process.cwd() + '/.localhostify.js');
45
const externalRedirects = Object.values(config).reduce((all, v) => [...all, ...v.externalRedirects], []);
@@ -23,4 +24,4 @@ fs.copyFileSync(__dirname + '/../chrome-ext/scripts/fetch.js', process.cwd() + '
2324
fs.copyFileSync(__dirname + '/../chrome-ext/assets/green.png', process.cwd() + '/localhostify-ext/assets/green.png');
2425
fs.copyFileSync(__dirname + '/../chrome-ext/assets/red.png', process.cwd() + '/localhostify-ext/assets/red.png');
2526

26-
console.log("Localhostify: Chrome Ext created in localhostify-ext folder.");
27+
console.log(`Localhostify ${version}: Chrome Ext created in localhostify-ext folder.`);

chrome-ext/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Localhostify",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"manifest_version": 2,
55
"description": "Localhostify: External redirects interceptor",
66
"author": "Salvatore Ravidà",

chrome-ext/scripts/http.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,14 @@ const { externalRedirects } = window.__LOCALHOSTIFY__;
66

77
let localhostifyEnabled = true;
88

9-
chrome.runtime.onInstalled.addListener(function () {
10-
chrome.storage.sync.set({ active: localhostifyEnabled }, function () {
11-
console.log('Active :', localhostifyEnabled);
12-
});
13-
});
14-
159
function onIconClick(toggle) {
1610
chrome.storage.sync.get(['active'], function (data) {
17-
const active = toggle ? !data.active : data.active;
11+
console.log('StorageGet Active :', JSON.stringify(data));
12+
const active = toggle ? !data.active : data.active === undefined ? localhostifyEnabled : data.active;
1813
localhostifyEnabled = active;
1914
chrome.browserAction.setIcon({ path: active ? 'assets/green.png' : 'assets/red.png' });
2015
chrome.storage.sync.set({ active }, function () {
21-
console.log('Active 1:', active);
16+
console.log('StorageSet Active set:', active);
2217
});
2318
});
2419
}
@@ -52,5 +47,5 @@ chrome.webRequest.onHeadersReceived.addListener(
5247
return { responseHeaders: headers };
5348
},
5449
{ urls: ['<all_urls>'] },
55-
['responseHeaders', 'blocking'],
50+
['blocking', 'responseHeaders', chrome.webRequest.OnHeadersReceivedOptions.EXTRA_HEADERS].filter(Boolean),
5651
);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "localhostify",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "Easy HTTP reverse proxy - localhost:3001 -> prod.domain.com",
55
"source": "src/index.js",
66
"main": "./dist/index.js",

0 commit comments

Comments
 (0)