Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

样式 & bugfix #1

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# which_host
a Chrome extension to show the IP of match hostnames
# which host
> a Chrome extension to show the IP of match hostnames

###[Available on Chrome App Store now!](https://chrome.google.com/webstore/detail/which-host/hjecimglpgbbajfigibmieancoegaema) :tada::tada:
### [Available on Chrome App Store now!](https://chrome.google.com/webstore/detail/which-host/hjecimglpgbbajfigibmieancoegaema) :tada::tada:


### Screenshots
Expand Down
24 changes: 13 additions & 11 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@ var getHostname = function (url) {
var whiteList = [];

var getConfig = function () {
var newWhiteList = [];
window.localStorage.getItem('config').split('\n').forEach(function (line) {
line = line.trim();
if (line.length > 0) {
try {
newWhiteList.push(new RegExp('^' + line + '$', 'i'));
} catch (e) {}
}

});
whiteList = newWhiteList;
var newWhiteList = [];
const config = window.localStorage.getItem('config');
if( config ) {
config.split('\n').forEach(function (line) {
line = line.trim();
if (line.length > 0) {
try {
newWhiteList.push(new RegExp('^' + line + '$', 'i'));
} catch (e) {}
}
});
whiteList = newWhiteList;
}
};

getConfig();
Expand Down
6 changes: 1 addition & 5 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@
"js": ["which_host.js"]
}
],
"permissions": [
"activeTab",
"https://ajax.googleapis.com/"
],
"background": {
"scripts": ["background.js"]
},
Expand All @@ -35,5 +31,5 @@
"*://*/"
],

"homepage_url": "https://github.com/loveky/which_host"
"homepage_url": "https://github.com/jdf2e/which_host"
}
5 changes: 3 additions & 2 deletions setting.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

body {
width: 400px;
height: 400px;
}

textarea {
Expand Down Expand Up @@ -44,5 +43,7 @@ textarea {
transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
-webkit-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
line-height: 1.42857143;
line-height: 1.42857143;
width: 100%;
box-sizing: border-box;
}
2 changes: 1 addition & 1 deletion setting.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<body>
<h1>which host to monitor</h1>
<p>Note: all regexp are used as case-insensitive</p>
<textarea id="config"></textarea>
<textarea id="config" placeholder="eg. baidu.com" autofocus></textarea>
<button id="save">Save</button>

<script type="text/javascript" src="setting.js"></script>
Expand Down
31 changes: 20 additions & 11 deletions which_host.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,11 @@
}

#which-host-container .item {
margin-top: 3px;
height: 19px;
height: 19px;
margin-bottom: 3px;
}

#which-host-container .item:first-child {
margin-top: 0;
}

#which-host-container .hostname, .ip {
.which-host-badge {
display: inline;
padding: .2em .6em .3em;
font-size: 75%;
Expand All @@ -36,21 +32,34 @@
text-align: center;
white-space: nowrap;
vertical-align: baseline;
border-radius: .25em;
}

.which-host-badge:first-child {
border-top-left-radius: .25em;
border-bottom-left-radius: .25em;
margin-left: 1px;
}

.which-host-badge:last-child {
border-top-right-radius: .25em;
border-bottom-right-radius: .25em;
margin-right: 1px;
}

.ip + .ip{
border-left: 1px solid #fff;
}

#which-host-container .hostname {
background: #337ab7;
margin-right: 5px;
}

#which-host-container .ip {
background: #5cb85c;
margin-right: 2px;
}

#which-host-container .internal {
background: #f0ad4e;
background: #f0ad4e;
}

#which-host-container .cache {
Expand Down
6 changes: 3 additions & 3 deletions which_host.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var getIPClassName = function (ip) {
return 'internal';
}

return ' ';
return 'ip';
}
};

Expand All @@ -54,9 +54,9 @@ var render = function () {

container.addEventListener('mouseenter', toggleClass, false);
}

Object.keys(cache).forEach(function (hostname) {
result.push('<div class="item"><span class="hostname">' + hostname + '</span>' + cache[hostname].map(function (ip) {return '<span class="ip ' + getIPClassName(ip) + '">' + ip + '</span>'}).join('') + '</div>');
result.push('<div class="item"><span class="which-host-badge hostname">' + hostname + '</span>' + cache[hostname].map(function (ip) {return '<span class="which-host-badge ' + getIPClassName(ip) + '">' + ip + '</span>'}).join('') + '</div>');
});

container.innerHTML = result.join(' ');
Expand Down