-
Notifications
You must be signed in to change notification settings - Fork 1
/
Shortcuts-As-Bookmarklet.html
181 lines (148 loc) · 5.2 KB
/
Shortcuts-As-Bookmarklet.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<head>
<title>Save Netflix Originator Shortcuts</title>
<meta charset="utf-8">
<meta property="og:type" content="article" />
<meta property="og:url" content="https://katzurki.github.io/nettufurikusu/shortcuts2bookmarklet.html" />
<meta property="og:title" content="Keyboard shortcuts export to bookmarklet." />
<meta property="og:description" content="https://katzurki.github.io/nettufurikusu" />
<style>
srt-html * {
color: #eeeeee !important;
background-color: #292929 !important;
}
img, video {z-index: 1}
* {border-color: #555555 !important}
cite, cite * {color: #029833 !important}
:link, :link * {color: #00AAEE !important}
input, textarea {background-color: #333333 !important}
a {background-color: rgba(255, 255, 255, 0.01) !important}
:visited, :visited * {color: rgb(211, 138, 138) !important}
html, html::before, body, body::before, input, select, button {background-image: none !important}
video {
background-color: transparent !important;
}
#page-wrap {
width: 900px;
margin: 0 auto;
}
a.btn {
background-color: #e3e3e3;
border-color: rgba(0,0,0,0.5);
display: inline-block;
color: #000;
text-transform: uppercase;
letter-spacing: 2px;
font-size: 12px;
padding: 10px 30px;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border: 2px solid rgba(0,0,0,0.3);
border-bottom-width: 3px;
}
a.btn:active {
background-color: #CCC;
border-color: rgba(0,0,0,0.9);
}
/* blue button */
div.text,
#content,
li[lang=ru] {
font: Verdana, Tahoma;
background: url('hatch.png') /* wtf? */; color: #CACACA !important;
width: 40%;
}
pre {
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
/* Internet Explorer 5.5+ */
}
@media screen and (-webkit-min-device-pixel-ratio: 0) {
body:first-of-type pre::after {
content: '' attr(class);
}
}
div.text,
#content,
body {
text-align: center;
background-color: #262626;
}
#page-wrap {
text-align: left;
width: 800px;
margin: 0 auto;
}
</style>
<script type="text/javascript">
console.log("Initialize setter.")
function fade(type, ms, el, remove = false) {
var isIn = type === 'in',
opacity = isIn ? 0 : 1,
interval = 50,
duration = ms,
gap = interval / duration
if (isIn) {
el.style.display = 'inline'
el.style.opacity = opacity
}
function func() {
opacity = isIn ? opacity + gap : opacity - gap
el.style.opacity = opacity
if (opacity <= 0) { remove ? el.remove() : el.style.display = 'none' }
if (opacity <= 0 || opacity >= 1) window.clearInterval(fading)
}
var fading = window.setInterval(func, interval)
}
debugger;
var longQuery = window.location.href
var flat = []
var tmpAr = []
var today = Date().replace(/ \d{2}:.+/gi,"").substr(4).replace(/ /gi,"-")
var h = document.location.href.indexOf("#")
var jsonPayload = longQuery.substr(h+1)
var ua = window.navigator.userAgent.toLowerCase();
var os = ua.includes("macintosh") && "osx" || ua.includes("linux") && "linux" || ua.includes("windows") && "windows"
var profileName = jsonPayload.replace(/:.+/gi,"")
jsonPayload = atob(jsonPayload.replace(/^.+?:/g,""))
var listForUser = JSON.parse(jsonPayload)["schema"];
tmpAr = tmpAr.concat(listForUser[0]["values"],listForUser[1]["values"],listForUser[2]["values"],listForUser[3]["values"])
flat=[]
for(i=0; i<tmpAr.length; i++){
var action = tmpAr[i]["name"]
var shortcut = tmpAr[i]["shortcuts"][os].replace(/Key|Digit/gi,"").replace(/\+/gi," + ")
flat.push({action, shortcut});
}
var listOfShortcuts = JSON.stringify(flat.sort(function(e,r) { return r["shortcut"].length - e["shortcut"].length } ),undefined,3)
var bookmarkletStub = `
{localStorage.setItem("originator.shortcuts.bindings",'JSONPAYLOADPLACEHOLDER');setTimeout(function(){location.reload();},2000)}
`
var bookmarkletReady = encodeURIComponent(bookmarkletStub.replace("JSONPAYLOADPLACEHOLDER",jsonPayload));
var bookmarkletReady = "javascript:(function()"+bookmarkletReady+")()"
window.onload = function(){var txtArea = document.getElementById("JSONDisplay")
txtArea.value = listOfShortcuts
txtArea.readOnly = true
txtArea.disabled = true
txtArea.style.color = "gold"
var placeHere = document.getElementById("validBookmarklet");
var a = document.createElement("a");
a.text = "Restore "+profileName+"'s Shortcuts from "+today
a.href = bookmarkletReady;
placeHere.appendChild(a);
}
</script>
</head>
<body>
<center>
<div class="srt-html">
<button id="validBookmarklet" style="background-color: #555555;"></button>
<br><font color="silver"><pre>If you see your own shortcuts displayed in the preview pane, the bookmarklet is ready to use.
Drag it to your Bookmark bar in Chrome and wait till the day you need to restore your shortcuts from it.
Then just click it once in an Originator task.
<font color="silver"><b><h2><pre>These are your current settings for shortcuts:</pre></h2></b>
</center>
<center>
<textarea style="border: 2px solid; color: yellow; background-color: black;" placeholder="" cols="60" rows="35" id="JSONDisplay" name="srtSource">
</textarea><br><br>