Last active
July 24, 2023 22:09
-
-
Save myfonj/045d42da5179cc93b3e90eaff0545d4c to your computer and use it in GitHub Desktop.
Bookmarklet using window.prompt as a REPL interface for current page. Keywordable.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript: (() => { | |
let doPrompt = true; | |
let promtLabel = ''; | |
let promptValue = '%s'; | |
if (promptValue == '\u0025s') { | |
promtLabel = 'Eval:'; | |
promptValue = '/* Expression like */ 1 + 1'; | |
} else { | |
doPrompt = false; | |
} | |
do { | |
try { | |
if (doPrompt) { | |
promptValue = prompt(promtLabel, promptValue); | |
if (promptValue === null) { | |
break; | |
} | |
} else { | |
doPrompt = true; | |
} | |
let result = eval(promptValue); | |
promtLabel = promptValue + '\n=\n' + result; | |
promptValue = promptValue/*.replace(/ \/\/= .*?$/, '') + ' //= ' + result;*/; | |
} catch (e) { | |
promtLabel = e; | |
} | |
} while (true); | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
document.forms[0].method = 'GET'
" or such.!
then you can do! 1 + 1
(enter) in URL bar and get the result. Again, only if page context permits execution and eval. So you can do! document.forms[0].method = 'get'
(enter)(escape), or continue further.