forked from iSwanGit/John-the-Defender
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
56 lines (46 loc) · 1.7 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
var curUrl;
var reqUrl;
var errFlag= false;
function getUrl() {
chrome.tabs.query({active: true, lastFocusedWindow: true}, function(tabs) {
tab= tabs[0];
curUrl= tab.url;
chrome.webRequest.onErrorOccurred.addListener(
function(details) {
if (errFlag == false) {
// net:: error detect (details.error (string))
// TODO: 에러별 구분
alert("error: " + details.error);
errFlag= true;
}
}, {
urls: ['*://*/*'],
types: ['xmlhttprequest']
}
);
if (!curUrl.search('http://')) { // http: true, https: false
reqUrl= curUrl.replace("http://", "https://");
// jquery: cross-domain http request
$.ajax({
url: reqUrl,
type: 'GET',
success: function(res, statusText, resObj) {
var contents= $(res.responseText);
var title= contents.find('title').text();
alert("오예 https 연결을 받는다구여");
//alert(res);
alert(resObj.getAllResponseHeaders());
alert(resObj.responseText);
alert(statusText, resObj);
}
});
}
// 처음부터 https 연결인 경우에는 체크하지 않음
});
}
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
if (changeInfo.status == 'complete') {
errFlag= false;
getUrl();
}
});