forked from ccforward/cc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
chenchen
committed
Apr 17, 2014
1 parent
9529401
commit ee2388e
Showing
30 changed files
with
20,964 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
chrome.extension.sendMessage({ | ||
links: sessionStorage['init-file-links'].split(','), | ||
scripts: sessionStorage['init-file-scripts'].split(','), | ||
location: document.location, | ||
localStg: { | ||
'request':localStorage["send_head_request"], | ||
'files':localStorage["monitor_files"] | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td,hr,button,article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section { | ||
margin: 0; | ||
padding: 0 | ||
} | ||
h1,h2,h3,h4,h5,h6 { | ||
font-size: 100%; | ||
font-weight: 500 | ||
} | ||
address,caption,cite,code,dfn,em,th,var { | ||
font-style: normal; | ||
font-weight: 500 | ||
} | ||
ol,ul { | ||
list-style: none | ||
} | ||
ins,a { | ||
text-decoration: none | ||
} | ||
a:hover { | ||
text-decoration: underline | ||
} | ||
|
||
::-webkit-scrollbar { | ||
width: 5px; | ||
} | ||
::-webkit-scrollbar-track { | ||
-webkit-border-radius: 6px; | ||
border-radius: 6px; | ||
background-color: transparent; | ||
} | ||
::-webkit-scrollbar-thumb { | ||
-webkit-border-radius: 6px; | ||
border-radius: 6px; | ||
background-color: #CECECE; | ||
} | ||
body { | ||
background: -webkit-gradient(linear, 0 0, 0 100%, from(#f7f7f7), to(#e0e0e0)); | ||
} | ||
|
||
.wrap { | ||
position: relative; | ||
width: 500px; | ||
padding: 30px 10px; | ||
} | ||
|
||
.reload-btn { | ||
position: absolute; | ||
right: 10px; | ||
top: 15px; | ||
width: 80px; | ||
padding: 6px; | ||
border-radius: 8px; | ||
border: 1px solid #bea280; | ||
background-color: #e38d27; | ||
color: #693e0a; | ||
text-align: center; | ||
text-decoration: none; | ||
text-shadow: 1px 1px 0 rgba(255,255,255,0.4); | ||
font-size: 12px; | ||
outline: none; | ||
cursor: pointer; | ||
} | ||
.reload-btn:hover { | ||
text-decoration: none; | ||
} | ||
.reload-btn:active { | ||
text-decoration: none; | ||
top: 18px; | ||
} | ||
.replace-js-btn { | ||
right: 113px; | ||
width: 37px; | ||
} | ||
|
||
.slider-btn { | ||
position: relative; | ||
display: block; | ||
width: 5.5em; | ||
height: 3em; | ||
cursor: pointer; | ||
border-radius: 1.5em; | ||
transition: 350ms; | ||
background: linear-gradient(rgba(0, 0, 0, 0.07), rgba(255, 255, 255, 0)), #ddd; | ||
box-shadow: 0 0.07em 0.1em -0.1em rgba(0, 0, 0, 0.4) inset, 0 0.05em 0.08em -0.01em rgba(255, 255, 255, 0.7); | ||
} | ||
|
||
.slider-btn::after { | ||
position: absolute; | ||
content: ''; | ||
width: 2em; | ||
height: 2em; | ||
top: 0.5em; | ||
left: 0.5em; | ||
border-radius: 50%; | ||
transition: 250ms ease-in-out; | ||
background: linear-gradient(#f5f5f5 10%, #eeeeee); | ||
box-shadow: 0 0.1em 0.15em -0.05em rgba(255, 255, 255, 0.9) inset, 0 0.2em 0.2em -0.12em rgba(0, 0, 0, 0.5); | ||
} | ||
.slider-btn::before { | ||
position: absolute; | ||
content: ''; | ||
width: 4em; | ||
height: 1.5em; | ||
top: 0.75em; | ||
left: 0.75em; | ||
border-radius: 0.75em; | ||
transition: 250ms ease-in-out; | ||
background: linear-gradient(rgba(0, 0, 0, 0.07), rgba(255, 255, 255, 0.1)), #d0d0d0; | ||
box-shadow: 0 0.08em 0.15em -0.1em rgba(0, 0, 0, 0.5) inset, 0 0.05em 0.08em -0.01em rgba(255, 255, 255, 0.7), 0 0 0 0 rgba(68, 204, 102, 0.7) inset; | ||
} | ||
.slider-btn.on::before { | ||
box-shadow: 0 0.08em 0.15em -0.1em rgba(0, 0, 0, 0.5) inset, 0 0.05em 0.08em -0.01em rgba(255, 255, 255, 0.7), 3em 0 0 0 rgba(68, 204, 102, 0.7) inset; | ||
} | ||
.slider-btn.on::after { | ||
left: 3em; | ||
} | ||
|
||
.files { | ||
margin-bottom: 10px; | ||
font-size: 14px; | ||
} | ||
.files .file-item { | ||
padding-bottom: 3px; | ||
margin-bottom: 6px; | ||
word-break: break-all; | ||
} | ||
.files .file-item label{ | ||
cursor: pointer; | ||
} | ||
.files .file-item .local-file { | ||
background-color: #DAF8C3; | ||
} | ||
.files .link-list { | ||
color: #35ADF0; | ||
} | ||
.files .script-list { | ||
color: #FC6C85; | ||
} | ||
.files .chkbox { | ||
margin-right: 5px; | ||
vertical-align: middle; | ||
} | ||
.files .title { | ||
padding: 5px 0; | ||
} | ||
#J_Current_URL { | ||
color:#4AAF73; | ||
cursor: pointer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
(function($){ | ||
|
||
var switchNode = $('#J_swicth_btn'), | ||
reload = $('#J_Reload'), | ||
monitorFiles = []; | ||
|
||
var chromeObj = { | ||
init: function(){ | ||
this._initData(); | ||
this._switch(); | ||
}, | ||
// 数据初始化 | ||
_initData: function(){ | ||
var _self = this; | ||
// 注入content | ||
chrome.windows.getCurrent(function (currentWindow) { | ||
chrome.tabs.query({ active: true, windowId: currentWindow.id }, function (activeTabs) { | ||
chrome.tabs.executeScript(activeTabs[0].id, { file: 'assets/content.js', allFrames: false }); | ||
}); | ||
}); | ||
|
||
// 回调函数 -- 监听接收的信息 | ||
chrome.extension.onMessage.addListener(function (message) { | ||
// 判断页面的localStorage 和 link script 标签 | ||
if(message.localStg.request > 0){ | ||
switchNode.addClass('on'); | ||
} | ||
// 显示link script url | ||
$('#J_Current_URL').html(message.location.href); | ||
_self._appendResource($('#J_Links'), message, 'links'); | ||
_self._appendResource($('#J_Scripts'), message, 'scripts'); | ||
|
||
|
||
message.localStg.files && $.merge(monitorFiles, message.localStg.files.split(',')); | ||
// 注册点击事件 | ||
_self._chkBox(); | ||
}); | ||
}, | ||
_appendResource: function(container, message, id){ | ||
// 先清空 | ||
container.html(''); | ||
var _self = this, | ||
monitorArr = []; | ||
// 正在监控的文件 | ||
if(message.localStg.files) | ||
monitorArr = message.localStg.files.split(','); | ||
$(message[id]).each(function(i, file){ | ||
|
||
// 判断本地js css | ||
var li = '<li class="file-item"><input type="checkbox" id="'+id + '_' + i + '" class="chkbox '; | ||
if($.inArray(file,monitorArr) > -1){ | ||
li+= 'chkbox-current'; | ||
} | ||
|
||
if(_self._isLocal(file, message.location)){ | ||
li += '"><label for="' + id + '_' + i + '" class="local-file J_Local">' + file; | ||
}else{ | ||
li += '"><label for="' + id + '_' + i + '" class="J_Remote">' + file; | ||
} | ||
li += '</label></li>'; | ||
container.append(li); | ||
$('.chkbox-current').prop('checked',true); | ||
|
||
// 判断本地的url | ||
if($.inArray(message.location.href, monitorArr) > -1) { | ||
$('#chk-local').prop('checked',true); | ||
} | ||
}); | ||
}, | ||
_isLocal: function(file, location){ | ||
var reg = new RegExp("^\\.|^\/(?!\/)|^[\\w]((?!://).)*$|" + location.protocol + "//" + location.host); | ||
return file.match(reg); | ||
}, | ||
_switch: function(){ | ||
var _self = this; | ||
reload.on('click', function(e){ | ||
e.preventDefault(); | ||
// 重置page的sessionStorage | ||
var code = 'sessionStorage["init-file-links"] = "";'+ | ||
'sessionStorage["init-file-scripts"] = "";'+ | ||
'document.location.reload();'; | ||
chrome.tabs.executeScript(null, {code: code}); | ||
// 填充新数据 | ||
_self._initData(); | ||
}); | ||
|
||
|
||
// switch | ||
switchNode.on('click', function(){ | ||
$(this).toggleClass('on'); | ||
if($(this).hasClass('on')){ | ||
// 开启捕获 | ||
var code = 'localStorage["send_head_request"] = 1' | ||
chrome.tabs.executeScript(null, {code: code}); | ||
}else { | ||
// 关闭捕获 | ||
var code = 'localStorage["send_head_request"] = -1' | ||
chrome.tabs.executeScript(null, {code: code}); | ||
} | ||
}); | ||
}, | ||
_chkBox: function(){ | ||
$('.chkbox').on('change', function(){ | ||
if($(this).prop('checked')){ | ||
// 填充到页面 | ||
var file = $(this).addClass('chkbox-current').siblings().html(); | ||
monitorFiles.push(file); | ||
var code = 'localStorage["monitor_files"] = ' + '"' + monitorFiles + '"'; | ||
chrome.tabs.executeScript(null, {code: code}); | ||
}else { | ||
$(this).removeClass('chkbox-current'); | ||
// 删除文件 | ||
monitorFiles.splice($.inArray($(this).siblings().html(),monitorFiles),1); | ||
|
||
var code = 'localStorage["monitor_files"] = ' + '"' + monitorFiles + '"'; | ||
chrome.tabs.executeScript(null, {code: code}); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
chromeObj.init(); | ||
|
||
})(jQuery); | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.