Skip to content

Commit d81ea30

Browse files
committed
update readme version 0.0.3
1 parent a0527c3 commit d81ea30

30 files changed

+79
-65
lines changed

.babelrc

100644100755
File mode changed.

.env

100644100755
File mode changed.

.gitattributes

100644100755
File mode changed.

.gitignore

100644100755
File mode changed.

README.md

100644100755
File mode changed.

_config.yml

100644100755
File mode changed.

package-lock.json

100644100755
File mode changed.

package.json

100644100755
File mode changed.

popup-page/App.jsx

100644100755
File mode changed.

popup-page/components/button.jsx

100644100755
File mode changed.

popup-page/components/header.jsx

100644100755
File mode changed.

popup-page/components/home.jsx

100644100755
Lines changed: 60 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -45,71 +45,30 @@ export class Home extends React.Component {
4545
closeAllParticlebutton: false,
4646
restoreAllParticlebutton: false
4747
};
48-
handleIncludeUrlChange() {
49-
console.log("this.state.checkBox", this.state.checkBox);
48+
componentDidMount() {
49+
//check if current tab is in hidden mode if yes then get settings
5050
urlUtilController.getCurrentOpenedTabHostName()
51+
.then((domain)=>{
52+
console.log(domain);
53+
if(domain!== undefined)
54+
return dBController.get(domain);
55+
throw new Error("undefined error");
56+
})
5157
.then((res)=>{
52-
if(this.state.checkBox=== false) {
53-
console.log("checkbox not checked" , this.state.checkBox);
54-
let putData = {};
55-
putData[res] = "getCurrentOpenedTabHostName";
56-
dBController.set(putData).then((resss)=>{
57-
console.log("" , resss);
58-
const checkBoxVal = this.state.checkBox;
59-
let checkBoxLabel = (checkBoxVal===false)?"This Domain is in Hidden mode":"Select this domain to hide from history.";
60-
this.setState({checkBox: !this.state.checkBox , checkBoxLabelValue: checkBoxLabel});
61-
}).catch((ee)=>{
62-
});
63-
}
64-
else {
65-
dBController.remove(res).then((res_str)=>{
66-
console.log("remove",res);
67-
this.setState({checkBox: false,checkBoxLabelValue: "Select this domain to hide from history."});
68-
})
69-
}
58+
console.log("getCurrentOpenedTabHostName",res);
59+
const key = Object.keys(res);
60+
return (key.length > 0) ? 1 : 0;
61+
})
62+
.then((res)=>{
63+
console.log(res);
64+
if(res===1)
65+
this.setState({checkBox: true, checkBoxLabelValue: "This Domain is in Hidden mode"});
66+
else
67+
this.setState({checkBox: false, checkBoxLabelValue: "Select this domain to hide from history."});
7068
})
7169
.catch((e)=>{
72-
alert(e);
73-
this.setState({checkBox: false});
70+
console.log(e);
7471
});
75-
if(this.state.checkBox === true) {
76-
this.setState({showCloseAlltab:true});
77-
chrome.browserAction.setBadgeText({text: '♥'});
78-
}
79-
else {
80-
/*
81-
* check if any other incognito tab is opened
82-
*/
83-
chrome.browserAction.setBadgeText({text: ''});
84-
}
85-
}
86-
constructor(props){
87-
super(props);
88-
this.handleCloseAll = this.handleCloseAll.bind(this);
89-
this.handleRestoreAll = this.handleRestoreAll.bind(this);
90-
this.handleIncludeUrlChange = this.handleIncludeUrlChange.bind(this);
91-
}
92-
componentDidMount() {
93-
//check if current tab is in hidden mode if yes then get settings
94-
urlUtilController.getCurrentOpenedTabHostName()
95-
.then((domain)=>{
96-
if(domain!== undefined)
97-
return dBController.get(domain);
98-
})
99-
.then((res)=>{
100-
console.log("getCurrentOpenedTabHostName",res);
101-
const key = Object.keys(res);
102-
return (key.length > 0) ? 1 : 0;
103-
})
104-
.then((res)=>{
105-
console.log(res);
106-
if(res===1)
107-
this.setState({checkBox: true, checkBoxLabelValue: "This Domain is in Hidden mode"});
108-
else
109-
this.setState({checkBox: false, checkBoxLabelValue: "Select this domain to hide from history."});
110-
}).catch((e)=>{
111-
alert(e);
112-
});
11372
//check if there any closed_tabs session is in the storage
11473
dBController.get("restore_tabs_url_list").then((dbres)=>{
11574
if(dbres.restore_tabs_url_list.length>0)
@@ -132,6 +91,42 @@ export class Home extends React.Component {
13291
console.log("checkIfIncognitoTabIsOpened",e);
13392
});
13493
}
94+
constructor(props){
95+
super(props);
96+
this.handleCloseAll = this.handleCloseAll.bind(this);
97+
this.handleRestoreAll = this.handleRestoreAll.bind(this);
98+
this.handleIncludeUrlChange = this.handleIncludeUrlChange.bind(this);
99+
}
100+
handleIncludeUrlChange() {
101+
urlUtilController.getCurrentOpenedTabHostName()
102+
.then((res)=>{
103+
if (this.state.checkBox === false) {
104+
/** when check box is selected */
105+
let putData = {};
106+
putData[res] = res;
107+
dBController.set(putData).then((resss)=>{
108+
this.setState({checkBox: !this.state.checkBox , checkBoxLabelValue: "This Domain is in Hidden mode.",showCloseAlltab: true});
109+
chrome.browserAction.setBadgeText({text: '♥'});
110+
urlUtilController.getCurrentOpenedTabUrl()
111+
.then(url=>{
112+
urlUtilController.removeUrlFromHistory(url).then((res_str)=>{}).catch((e)=>{});
113+
})
114+
.catch(e=> {
115+
console.log(e);
116+
});
117+
}).catch((ee)=>{});
118+
} else {
119+
/** when check box is unchecked */
120+
this.setState({checkBox: !this.state.checkBox , checkBoxLabelValue: "Select this domain to hide from history."});
121+
chrome.browserAction.setBadgeText({text: ''});
122+
}
123+
})
124+
.catch(e=> {
125+
/** TABS which are not accessed from chrome extension eg. blank tab , chrome store webpage etc. */
126+
this.setState({checkBoxLabelValue: "This url can't be taken in Incognito mode"});
127+
})
128+
}
129+
135130
handleCloseAll(){
136131
this.setState({closeAllParticlebutton: true,restoreAllParticlebutton: false});
137132
urlUtilController.closeAllCurrentBlockedUrlTabs()
@@ -204,8 +199,12 @@ export class Home extends React.Component {
204199
</FormGroup>
205200
</Typography>
206201
</Paper>}
202+
<Divider variant="middle" />
203+
<div>
204+
Creator @<a href="https://github.com/fxnoob/" target="_blank">fxnoob</a> made with ♥ and this <a href="https://github.com/fxnoob/chrome-extension-boilerplate" target="_blank">chrome extension boilerplate</a> at <a href="https://github.com/nosemantic/" target="_blank">nosemantic</a>
205+
</div>
207206
</div>
208207
);
209208
}
210209
}
211-
export default withStyles(styles)(Home);
210+
export default withStyles(styles)(Home);

popup-page/components/index.jsx

100644100755
File mode changed.

popup-page/components/particles.jsx

100644100755
File mode changed.

popup-page/popup.html

100644100755
File mode changed.

src/app/_locales/en/messages.json

100644100755
File mode changed.

src/app/images/favicon.ico

100644100755
File mode changed.

src/app/images/icon-128.png

100644100755
File mode changed.

src/app/images/icon-16.png

100644100755
File mode changed.

src/app/images/icon-32.png

100644100755
File mode changed.

src/app/manifest.json

100644100755
File mode changed.

src/app/popup.html

100644100755
File mode changed.

src/app/styles/main.css

100644100755
File mode changed.

src/background.js

100644100755
File mode changed.

src/background.test.js

100644100755
File mode changed.

src/data/websites.json

100644100755
File mode changed.

src/utils/db.js

100644100755
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default class Db {
99
set(params) {
1010
return new Promise((resolve, reject) => {
1111
try {
12-
chrome.storage.sync.set(params, function(){
12+
chrome.storage.sync.set(params, ()=>{
1313
resolve(params);
1414
});
1515
}
@@ -25,7 +25,7 @@ export default class Db {
2525
get(params) {
2626
return new Promise((resolve, reject) => {
2727
try {
28-
chrome.storage.sync.get(params, function(items){
28+
chrome.storage.sync.get(params, (items)=>{
2929
if(items === undefined)
3030
reject("Error");
3131
else
@@ -53,4 +53,4 @@ export default class Db {
5353
}
5454
})
5555
}
56-
}
56+
}

src/utils/urlutil.js

100644100755
Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,21 @@ export default class urlUtil {
189189
}
190190
});
191191
}
192+
getCurrentOpenedTabUrl() {
193+
return new Promise((resolve, reject) => {
194+
try {
195+
chrome.tabs.query({active: true, currentWindow: true }, (tabs)=>{
196+
if(tabs[0].url === undefined || tabs[0].url === null)
197+
reject("Null or Undefined url");
198+
else
199+
resolve(tabs[0].url);
200+
});
201+
}
202+
catch (e) {
203+
reject(e);
204+
}
205+
});
206+
}
192207
/*
193208
* set badge on action icon
194209
* */
@@ -214,4 +229,4 @@ export default class urlUtil {
214229
});
215230
});
216231
}
217-
};
232+
};

src/utils/urlutil.test.js

100644100755
File mode changed.

webpack.config.js

100644100755
File mode changed.

0 commit comments

Comments
 (0)