| 1 | + | <!DOCTYPE html> |
| 2 | + | <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> |
| 3 | + | |
| 4 | + | <head> |
| 5 | + | <!-- Metadata --> |
| 6 | + | <meta charset="utf-8" /> |
| 7 | + | <meta name="author" content="Jacob Strieb" /> |
| 8 | + | <meta name="description" content="Create hidden, secret bookmarks for locked, password-protected links." /> |
| 9 | + | <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> |
| 10 | + | |
| 11 | + | <link rel="shortcut icon" type="image/x-icon" href="../favicon.ico"> |
| 12 | + | |
| 13 | + | <title>Create Hidden Bookmarks</title> |
| 14 | + | |
| 15 | + | <!-- Styles --> |
| 16 | + | <link rel="stylesheet" href="../style.css" type="text/css" /> |
| 17 | + | |
| 18 | + | <!-- Scripts --> |
| 19 | + | <script type="text/javascript" src="../b64.js"></script> |
| 20 | + | <script type="text/javascript" src="../api.js"></script> |
| 21 | + | <script type="text/javascript" src="hidden.js"> </script> |
| 22 | + | </head> |
| 23 | + | |
| 24 | + | <body onload="main()"> |
| 25 | + | <!-- View on GitHub ribbon --> |
| 26 | + | <a href="https://github.com/jstrieb/link-lock" target="_blank"> |
| 27 | + | <img class="ribbon" src="../corner-ribbon-minified.svg" alt="View on GitHub" /> |
| 28 | + | </a> |
| 29 | + | |
| 30 | + | <!-- Explanation for those who do not have JavaScript enabled --> |
| 31 | + | <noscript> |
| 32 | + | <div class="red-border"> |
| 33 | + | <p>If you are seeing this, it means that you have JavaScript disabled. Please enable JavaScript to access the locked link.</p> |
| 34 | + | |
| 35 | + | <p>This application is entirely programmed in JavaScript. This was done intentionally, so that all encryption and decryption happens client-side. This means the code runs as a distributed application, relying only on GitHub Pages for infrastructure. It also means that no data about locked links is ever stored on a server. The code is designed to be auditable so users can investigate what is happening behind the scenes.</p> |
| 36 | + | |
| 37 | + | <p>If you still want to run the application, I encourage you to clone the <a href="https://github.com/jstrieb/link-lock">source code on GitHub</a>. That way you can disable JavaScript only for trusted files on your local machine.</p> |
| 38 | + | </div> |
| 39 | + | </noscript> |
| 40 | + | |
| 41 | + | <!-- Display errors in a big red box --> |
| 42 | + | <div class="error red-border" style="display: none"> |
| 43 | + | <p id="errortext">Error</p> |
| 44 | + | <button onclick="main()">Try again</button> |
| 45 | + | <a href="https://jstrieb.github.io/link-lock"><button>Lock a link</button></a> |
| 46 | + | </div> |
| 47 | + | |
| 48 | + | <h1>Create Hidden Bookmarks</h1> |
| 49 | + | <p>It is possible to protect bookmarks with a password using <a href="https://jstrieb.github.io/link-lock" target="_blank">Link Lock</a>, but a link that needs a password may appear suspicious to someone else seeing it. Hidden bookmarks solve this problem.</p> |
| 50 | + | <p>Hidden bookmarks are disguised to be identical to normal bookmarks, with one exception: clicking them in the right order will open a hidden link. <b>To open the hidden link, click the disguised bookmark first, and then click the decrypt bookmark next.</b> The same decrypt bookmark works for all disguised bookmarks.</p> |
| 51 | + | |
| 52 | + | <p>Here is how to create hidden bookmarks:</p> |
| 53 | + | <ol> |
| 54 | + | <li> |
| 55 | + | Drag the "decrypt" bookmark below to your bookmarks bar. |
| 56 | + | |
| 57 | + | <ul><li style="margin-bottom: 0.5em;">Clicking the decrypt bookmark goes to <code>gmail.com</code> unless the current page is a disguised link. Use the "advanced" options to have it go somewhere else instead.</li></ul> |
| 58 | + | |
| 59 | + | <style> |
| 60 | + | .inline-button-container { |
| 61 | + | display: flex; |
| 62 | + | width: 100%; |
| 63 | + | } |
| 64 | + | |
| 65 | + | .inline-button-container * { |
| 66 | + | margin: 5px; |
| 67 | + | } |
| 68 | + | |
| 69 | + | .inline-button-container input { |
| 70 | + | margin-left: 0; |
| 71 | + | } |
| 72 | + | |
| 73 | + | #advanced-label { |
| 74 | + | margin-top: 0em; |
| 75 | + | } |
| 76 | + | |
| 77 | + | code { |
| 78 | + | font-family: monospace, monospace; |
| 79 | + | padding: 0 3px; |
| 80 | + | } |
| 81 | + | |
| 82 | + | .advanced p { |
| 83 | + | margin-top: 0; |
| 84 | + | margin-bottom: 0.5em; |
| 85 | + | } |
| 86 | + | |
| 87 | + | button { |
| 88 | + | white-space: nowrap; |
| 89 | + | } |
| 90 | + | </style> |
| 91 | + | <details> |
| 92 | + | <summary id="advanced-label">advanced</summary> |
| 93 | + | <div class="advanced" id="advanced"> |
| 94 | + | <!-- |
| 95 | + | <p>Input a new location decoy location for the decrypt bookmark:</p> |
| 96 | + | --> |
| 97 | + | <label for="decrypt-bookmark-disguise">decoy location for decrypt bookmark</label> |
| 98 | + | <div class="inline-button-container"> |
| 99 | + | <input type="text" id="decrypt-bookmark-disguise" value="https://gmail.com" /> |
| 100 | + | <button onclick="onChangeDecrypt()">Change Location</button> |
| 101 | + | <div> |
| 102 | + | </div> |
| 103 | + | </details> |
| 104 | + | |
| 105 | + | <p><a class="bookmark" id="decrypt-bookmark" onclick="return false;" href='javascript:(() => { |
| 106 | + | |
| 107 | + | var b64 = (() => { |
| 108 | + | |
| 109 | + | function generateIndexDict(a) { |
| 110 | + | let result = {}; |
| 111 | + | for (let i = 0; i < a.length; i++) { |
| 112 | + | result[a[i]] = i; |
| 113 | + | } |
| 114 | + | return result; |
| 115 | + | } |
| 116 | + | |
| 117 | + | const _a = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; |
| 118 | + | const _aRev = generateIndexDict(_a); |
| 119 | + | _aRev["-"] = _aRev["+"]; |
| 120 | + | _aRev["_"] = _aRev["/"]; |
| 121 | + | |
| 122 | + | const _enc = new TextEncoder("utf-8"); |
| 123 | + | const _dec = new TextDecoder("utf-8"); |
| 124 | + | |
| 125 | + | return { |
| 126 | + | |
| 127 | + | decode: function(s) { |
| 128 | + | return this.binaryToAscii(this.base64ToBinary(s)); |
| 129 | + | }, |
| 130 | + | |
| 131 | + | encode: function(s) { |
| 132 | + | return this.binaryToBase64(this.asciiToBinary(s)); |
| 133 | + | }, |
| 134 | + | |
| 135 | + | asciiToBinary: function(text) { |
| 136 | + | return _enc.encode(text); |
| 137 | + | }, |
| 138 | + | |
| 139 | + | |
| 140 | + | binaryToAscii: function(binary) { |
| 141 | + | return _dec.decode(binary); |
| 142 | + | }, |
| 143 | + | |
| 144 | + | |
| 145 | + | binaryToBase64: function(originalBytes) { |
| 146 | + | let length = originalBytes.length; |
| 147 | + | let added = (length % 3 == 0) ? 0 : (3 - length % 3); |
| 148 | + | let bytes = new Uint8Array(length + added); |
| 149 | + | bytes.set(originalBytes); |
| 150 | + | |
| 151 | + | let output = ""; |
| 152 | + | for (let i = 0; i < bytes.length; i += 3) { |
| 153 | + | output += _a[ bytes[i] >>> 2 ]; |
| 154 | + | output += _a[ ((bytes[i] & 0x3) << 4) | (bytes[i + 1] >>> 4) ]; |
| 155 | + | output += _a[ ((bytes[i + 1] & 0xF) << 2) | (bytes[i + 2] >>> 6) ]; |
| 156 | + | output += _a[ bytes[i + 2] & 0x3F ]; |
| 157 | + | } |
| 158 | + | |
| 159 | + | if (added > 0) { |
| 160 | + | output = output.slice(0, -added) + ("=".repeat(added)); |
| 161 | + | } |
| 162 | + | |
| 163 | + | return output; |
| 164 | + | }, |
| 165 | + | |
| 166 | + | base64ToBinary: function(s) { |
| 167 | + | let bytes = []; |
| 168 | + | |
| 169 | + | if (s.length % 4 == 1) { |
| 170 | + | throw "Invalid base64 input"; |
| 171 | + | } else if (s.length % 4 != 0) { |
| 172 | + | s += "=".repeat(4 - (s.length % 4)); |
| 173 | + | } |
| 174 | + | |
| 175 | + | for (let i = 0; i <= (s.length - 4); i += 4) { |
| 176 | + | for (let j = 0; j < 4; j++) { |
| 177 | + | if (s[i + j] != "=" && !(s[i + j] in _aRev)) { |
| 178 | + | throw "Invalid base64 input"; |
| 179 | + | } else if (s[i + j] == "=" && Math.abs(s.length - (i + j)) > 2) { |
| 180 | + | throw "Invalid base64 input"; |
| 181 | + | } |
| 182 | + | } |
| 183 | + | |
| 184 | + | bytes.push((_aRev[s[i]] << 2) | (_aRev[s[i + 1]] >>> 4)); |
| 185 | + | if (s[i + 2] != "=") { |
| 186 | + | bytes.push(((_aRev[s[i + 1]] & 0xF) << 4) | (_aRev[s[i + 2]] >>> 2)); |
| 187 | + | } |
| 188 | + | if (s[i + 3] != "=") { |
| 189 | + | bytes.push(((_aRev[s[i + 2]] & 0x3) << 6) | _aRev[s[i + 3]]); |
| 190 | + | } |
| 191 | + | } |
| 192 | + | |
| 193 | + | return new Uint8Array(bytes); |
| 194 | + | } |
| 195 | + | |
| 196 | + | } |
| 197 | + | })(); |
| 198 | + | |
| 199 | + | const hash = window.location.hash.slice(1); |
| 200 | + | try { |
| 201 | + | const decoded = b64.decode(hash); |
| 202 | + | const params = JSON.parse(decoded); |
| 203 | + | window.location.href = "https://jstrieb.github.io/link-lock/" + window.location.hash; |
| 204 | + | } catch { |
| 205 | + | window.location.replace("https://gmail.com"); |
| 206 | + | } |
| 207 | + | |
| 208 | + | })();'>Decrypt</a></p> |
| 209 | + | </li> |
| 210 | + | <li>It may be a good idea to rename the decrypt bookmark to "Gmail" by right clicking, and either clicking "Edit" or "Properties."</li> |
| 211 | + | <li> |
| 212 | + | Fill in the hidden URL below (if it is not already filled in). Then, fill in the disguised bookmark name and link. |
| 213 | + | <ul><li>There is a button to generate random disguise links if you do not want to pick your own.</li></ul> |
| 214 | + | </li> |
| 215 | + | <li>Press the button to create the bookmark. Once created, drag the disguised bookmark to your bookmarks bar.</li> |
| 216 | + | </ol> |
| 217 | + | |
| 218 | + | <hr /> |
| 219 | + | |
| 220 | + | <div class="form"> |
| 221 | + | <label for="encrypted-url">hidden url</label> |
| 222 | + | <input type="url" id="encrypted-url" oninput="document.querySelector('.alert').style.opacity = 0" /> |
| 223 | + | <label for="bookmark-title">disguised bookmark name</label> |
| 224 | + | <input type="text" id="bookmark-title" /> |
| 225 | + | <label for="bookmark-url">bookmark disguise url</label> |
| 226 | + | <input type="url" id="bookmark-url" required /> |
| 227 | + | <button onclick="onHide()">Create Disguised Bookmark</button> |
| 228 | + | <button onClick="randomLink()">Use A Random Disguise Link</button> |
| 229 | + | <p class="alert">INVISIBLE</p> |
| 230 | + | </div> |
| 231 | + | |
| 232 | + | <hr /> |
| 233 | + | |
| 234 | + | <!-- Output area --> |
| 235 | + | <style> |
| 236 | + | .output label[for="output"] { |
| 237 | + | margin-bottom: 1em; |
| 238 | + | } |
| 239 | + | </style> |
| 240 | + | <div class="output"> |
| 241 | + | <label for="output">output</label> |
| 242 | + | <!-- (Leg) disabled (by acid) --> |
| 243 | + | <a class="bookmark" href="" onclick="return false;" aria-disabled="true" id="output">No Disguised Bookmark Created Yet</a> |
| 244 | + | <p>Drag the disguised bookmark above to the bookmarks bar.</p> |
| 245 | + | <p>To access the hidden link, click the disguised bookmark, then the decrypt bookmark (which may have been renamed to "Gmail").</p> |
| 246 | + | </div> |
| 247 | + | |
| 248 | + | <!-- Page footer --> |
| 249 | + | <footer> |
| 250 | + | <hr /> |
| 251 | + | <p class="copyright">Created by <a href="https://jstrieb.github.io">Jacob Strieb</a>.</p> |
| 252 | + | </footer> |
| 253 | + | </body> |
| 254 | + | </body> |
| 255 | + | |
| 256 | + | </html> |
| 257 | + | |