Skip to content

Commit

Permalink
opencpnnect first version
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-hanheide committed Jun 18, 2020
1 parent 09644d1 commit 69135c2
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 24 deletions.
Binary file modified icons/128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/26.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/logo-old.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed icons/logo.png
Binary file not shown.
1 change: 1 addition & 0 deletions icons/logo.png
Binary file modified icons/openconnect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions scripts/background.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<script src="domain_list.js"></script>
<script src="popup.js"></script>
<!--<script src="domain_list.js"></script>
<script src="popup.js"></script>-->
1 change: 0 additions & 1 deletion scripts/domain_list.js

This file was deleted.

27 changes: 26 additions & 1 deletion scripts/popup.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,27 @@
<script src="domain_list.js"></script>
<html>
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<title>Openconnect Wizard</title>
</head>
<body>
<div class="container-fluid" style="min-width:400px;">
<div class="row"><div class="col">

<div id="available" style="display: none;">
<h3>openconnect command string</h3>
<div class="form-group">
<label for="cmd_line">command line (Linux); click to copy and paste into terminal:</label>
<textarea id="cmd_line" readonly style="font-family: monospace; min-width: 100%; min-height: 100px;" class="form-control js-copytextarea js-textareacopybtn"></textarea>
</div>
</div>
<div id="unavailable">
<div id="available">
<div class="alert alert-warning" role="alert">
Sorry, couldn't find the VPN cookie on this page.
</div>
</div>
</div></div>
</div>
<script src="popup.js"></script>
</body>
</html>
63 changes: 43 additions & 20 deletions scripts/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,46 +16,69 @@ function getDomain(e) {
return domain
}


function url_domain(data) {
var a = document.createElement('a');
a.href = data;
return a.hostname;
}

var content = "",
downloadable = "",
popup = "",
jsons = [];


var copyTextareaBtn = document.querySelector('.js-textareacopybtn');
var copyTextarea = document.querySelector('.js-copytextarea');
var div_available = document.querySelector('#available');
var div_unavailable = document.querySelector('#unavailable');

chrome.tabs.getSelected(null, function(e) {

//下面就是修改自cookies.txt插件的版本

domain = getDomain(e.url);
//domain = getDomain(e.url);
domain = url_domain(e.url);
chrome.cookies.getAll({}, function(o) {

for (var t in o) {
cookie = o[t];

if (-1 != cookie.domain.indexOf(domain)) {
//变成json的地方,可以在这里添加更多关于json的属性
jsons.push({
name : escapeForPre(cookie.name),
value: escapeForPre(cookie.value),
domain: escapeForPre(cookie.domain),
path : escapeForPre(cookie.path),
expires : escapeForPre(cookie.expirationDate ? cookie.expirationDate : "0")

});

if (cookie.name == 'webvpn') {
content +=
"sudo openconnect --cookie="
+ escapeForPre(cookie.value)
+ " "
+ escapeForPre(cookie.domain);
div_unavailable.style.display = "none";
div_available.style.display = "block";
break;
}
};
}

copyTextarea.cols = content.length;
copyTextarea.value = content;
//变成可以看的json string
content += JSON.stringify(jsons, null, 2);
//content += JSON.stringify(jsons, null, 2);

//下载链接
var downloadLinkContent = "data:application/octet-stream;base64," + btoa(content);
var downloadLink = "<a href=" + downloadLinkContent + ' download="cookies.json">download as json file</a>';
//var downloadLinkContent = "data:application/octet-stream;base64," + btoa(content);
//var downloadLink = "<a href=" + downloadLinkContent + ' download="cookies.json">download as json file</a>';

document.write('<pre>\n'+ downloadLink +'\n\n'+content+'</pre>');
//document.write(content);

});
});



copyTextarea.addEventListener('click', function(event) {
copyTextarea.focus();
copyTextarea.select();

try {
var successful = document.execCommand('copy');
var msg = successful ? 'successful' : 'unsuccessful';
console.log('Copying text command was ' + msg);
} catch (err) {
console.log('Oops, unable to copy');
}
});

0 comments on commit 69135c2

Please sign in to comment.