-
Notifications
You must be signed in to change notification settings - Fork 0
/
shortcut-encode.js
25 lines (20 loc) · 982 Bytes
/
shortcut-encode.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
javascript:
// detect if user select a text
var text = '' +
(window.getSelection ? window.getSelection() :
(document.getSelection ? document.getSelection() : document.selection.createRange().text));
// trim spaces
text = text.trim();
// if no selected text, ask user to enter the text
var p = !text||text=='' ? prompt('_lang{Please enter the text to encode into Base64 string}') : text;
// if length of input reachs max, alert to use post method
if( p.length>1950 ) {
if( true==confirm('_lang{The tool could not process this input directly, please access the website to re-enter this input to process again}') )
window.open('https://[=PSZ_APP_SITE_DOMAIN=]/[=TOOL_SLUG=].html?lang=[=CURRENT_LANGUAGE_CODE=]');
void(0);
exit;
}
// all ok, open tool in new tab
window.open('https://[=PSZ_APP_SITE_DOMAIN=]/[=TOOL_SLUG=].html?lang=[=CURRENT_LANGUAGE_CODE=]&utm_source=shortcut&input=' + p);
void(0); // this void prevents direction of current page
exit;