-
-
Save jeroenvandijk/2c54cfcfacd61a97962c0504a77cacc3 to your computer and use it in GitHub Desktop.
This file contains 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
(defn bookmarklet-url [] | |
(let [sci-url "https://cdn.jsdelivr.net/npm/@borkdude/sci@0.0.13-alpha.6/sci.js" | |
code '(println "hi" (+ 1 2)) ;; not support yet | |
code '(str "sum " (+ 1 2 3 4 5 6 7))] | |
(str "javascript:(function(){var s=document.createElement('script');s.onload=function(){alert(sci.evalString('" (clojure.string/replace (pr-str code) "\"" "%22") | |
"'))};s.setAttribute('src','" sci-url "');document.body.appendChild(s);})();"))) | |
(defn bookmarklet-link [link] | |
(str "<a href=\"" (bookmarklet-url) "\">" link "</a>")) | |
(println (generate-bookmarklet)) | |
(println (bookmarklet-link "take 4")) |
This file contains 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
<a href="javascript:(function(){ | |
script = document.createElement('script'); | |
script.onload = function(){ alert('Loaded!'); }; | |
script.setAttribute('src','https://cdn.jsdelivr.net/npm/@borkdude/sci@0.0.13-alpha.6/sci.js?i=' + Math.random()); | |
document.body.appendChild(script); | |
})();"> Bookmark JS</a> | |
<a href="javascript:(function(){var s=document.createElement('script');s.onload=function(){alert(sci.evalString('(str %221%22 2)'))};s.setAttribute('src','https://cdn.jsdelivr.net/npm/@borkdude/sci@0.0.13-alpha.6/sci.js');document.body.appendChild(s);})();"> Bookmark JS 2</a> | |
<a href="javascript:(function(){var s=document.createElement('script');s.onload=function(){alert(sci.evalString((.log js/console (println %22hi%22 (+ 1 2)))))};s.setAttribute('src','https://cdn.jsdelivr.net/npm/@borkdude/sci@0.0.13-alpha.6/sci.js');document.body.appendChild(s);})();"> Bookmark JS 3</a> | |
<a href="javascript:(function(){var s=document.createElement('script');s.onload=function(){alert(sci.evalString('(println %22hi%22 (+ 1 2))'))};s.setAttribute('src','https://cdn.jsdelivr.net/npm/@borkdude/sci@0.0.13-alpha.6/sci.js');document.body.appendChild(s);})();">take 4</a> | |
Working version! | |
<a href="javascript:(function(){var s=document.createElement('script');s.onload=function(){alert(sci.evalString('(str %22sum %22 (+ 1 2 3 4 5 6 7))'))};s.setAttribute('src','https://cdn.jsdelivr.net/npm/@borkdude/sci@0.0.13-alpha.6/sci.js');document.body.appendChild(s);})();">take 4</a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment