-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
133 lines (127 loc) · 5.66 KB
/
index.html
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<!DOCTYPE html>
<html>
<head>
<title>花密</title>
<meta charset="UTF-8" />
<meta http-equiv="Content-Type" content="text/html" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimal-ui" />
<script>
if (typeof module === 'object') {
window.module = module; module = undefined;
}
</script><!-- solve the electron-jquery conflict -->
<script src="res/lib/jquery-3.3.1.min.js"></script>
<script src="res/lib/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="res/lib/bootstrap.min.css" />
<script src="res/lib/all.js"></script>
<script src="res/lib/v4-shims.js"></script><!-- font-awesome 5 use as 4 -->
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div class="d-flex mx-auto justify-content-center align-items-center text-dark" id="main">
<div id="controller">
<a href="javascript:require('electron').shell.openExternal(require('./package.json').homepage)"
class="small flower"><i class="fa fa-info fa-fw" title="关于"></i></a>
<a href="settings.html" class="small flower"><i class="fa fa-cog fa-fw" title="设置"></i></a>
<a href="javascript:winhider()" class="small flower" id="win-hider"><i class="fa fa-sort-desc fa-fw"
title="最小化到托盘"></i></a><span id="no-use-space"> </span>
<a href="javascript:window.close()" class="small flower"><i class="fa fa-times fa-fw"
title="退出"></i></a>
</div>
<div id="set" class="justify-content-center">
<br />
<input name="password" id="password" placeholder="记忆密码" type="password" class="lead form"
autofocus /><br /><br />
<input name="key" id="key" placeholder="区分代号" type="text" class="lead form" /><br /><br />
<p id="code" class="small text-black-50">按下<b>Enter</b>键来获取代码<br /><span id="tipautohide">将会自动复制并退出</span>
</p>
</div><br />
</div>
<script>
const Store = require('electron-store');
const store = new Store();
const clipboard = require('electron').clipboard;
const ipc = require('electron').ipcRenderer;
const remote = require('electron').remote;
const Menu = remote.Menu;
const MenuItem = remote.MenuItem;
const menu = new Menu()
const md5 = require('blueimp-md5');
if (!store.get("autohide")) $("#tipautohide").css("display", "none");
function winhider() {
ipc.send("winhider");
}
function submitter() {
var password = $("#password").val();
var key = $("#key").val();
if (password && key) {
var md5one = md5(password, key);
var md5two = md5(md5one, 'snow');
var md5three = md5(md5one, 'kise');
//计算大小写
var rule = md5three.split("");
var source = md5two.split("");
for (var i = 0; i <= 31; i++) {
if (isNaN(source[i])) {
str = "sunlovesnow1990090127xykab";
if (str.search(rule[i]) > -1) {
source[i] = source[i].toUpperCase();
}
}
}
var code32 = source.join("");
var code1 = code32.slice(0, 1);
if (isNaN(code1)) {
var code16 = code32.slice(0, 16);
} else {
var code16 = "K" + code32.slice(1, 16);
}
if (store.get("longmode")) {
if (store.get("autocopy")) {
clipboard.writeText(code32);
if (store.get("autohide")) {
winhider();
$("#password").val("");
$("#key").val("");
} else
$("#code").text(code32);
} else
$("#code").text(code32);
}
else {
if (store.get("autocopy")) {
clipboard.writeText(code16);
if (store.get("autohide")) {
winhider();
$("#password").val("");
$("#key").val("");
} else
$("#code").text(code16);
} else
$("#code").text(code16);
}
//$("#code32").text(code32);
//$("#code6").text(password);
} else {
$('#code').html("<b>没有足够信息,请输入完整</b>");
}
}
function keydown(e) {
var currKey = 0, e = e || event;
if (e.keyCode == 13) {
submitter();
}
}
document.onkeydown = keydown;//Enter->提交
menu.append(new MenuItem({ role: 'copy', label: '复制' }))
menu.append(new MenuItem({ type: 'separator' }))
menu.append(new MenuItem({ role: 'paste', label: '粘贴' }))
menu.append(new MenuItem({ type: 'separator' }))
menu.append(new MenuItem({ label: '提交', click() { submitter() } }))
window.addEventListener('contextmenu', (e) => {
e.preventDefault()
menu.popup({ window: remote.getCurrentWindow() })
}, false)//右键菜单
</script>
</body>
</html>