scittle

henrik42 2024-07-18T09:23:14.488839Z

Hey, scittle newbie here. I'm using https://gist.github.com/henrik42/f9e1977a35380bb28829c06301509841 with https://babashka.org/scittle/bookmarklet.html?gist=henrik42/f9e1977a35380bb28829c06301509841. I'm trying to build a bookmarklet that opens a react gui. So far it seems to run "kind of". In firefox I can inspect the DOM and there I see a <div>Hello world!</div> element but nothing shows in the page. I suspect this may have something to do how firefox builds the DOM for javascript:-URLs but I'm really just guessing. Any help/pointers?

henrik42 2024-07-19T08:45:28.557389Z

@borkdude Just as a follow up: I noticed, the the Scittle Bookmarklet creator produces https://babashka.github.io/scittle/js/scittle.js for the download URL and this redirects to https://babashka.org/scittle/js/scittle.js which makes my firefox download the code twice. I couldn't find the source on github. Are the sources publicy available?

borkdude 2024-07-19T10:06:12.096369Z

Use the CDN links might help solve the problem

borkdude 2024-07-19T14:49:55.584639Z

@henrikheine I mean these links: https://github.com/babashka/scittle/releases/tag/v0.6.17

borkdude 2024-07-19T14:51:47.246159Z

Maybe I didn't understand your question properly. Feel free to follow up

borkdude 2024-07-18T10:44:03.062279Z

FWIW, when I change .appendChild to .prepend and then click the link it works for me

borkdude 2024-07-18T10:46:19.913939Z

also it works when I click the link after the page was loaded , perhaps the code just isn't run on load

henrik42 2024-07-18T10:58:19.433039Z

You mean, you change "(js/document.body.appendChild app)" to "(js/document.body.prepend app)" and follow the https://babashka.org/scittle/bookmarklet.html?name=scittle-example-1&amp;code=(ns%20example-1)%0A%0A(def%20app%20(js%2Fdocument.createElement%20%22div%22))%0A(js%2Fdocument.body.prepend%20app)%0A%0A(defn%20load-script%20%5Bsrc%20callback-str%5D%0A%20%20(js%2Fconsole.log%20(str%20%22load-script%3A%20src%3D%22%20src%20%22%20callback%3D%22%20callback-str))%0A%20%20(js%2Fdocument.body.appendChild%0A%20%20%20(doto%20(js%2Fdocument.createElement%20%22script%22)%0A%20%20%20%20%20(.setAttribute%20%22onLoad%22%20(str%20%22scittle.core.eval_string(%5C%22%22%20callback-str%20%22%5C%22)%22))%0A%20%20%20%20%20(.setAttribute%20%22src%22%20src))))%0A%0A(defn%20load-reagent%20%5B%5D%0A%20%20(load-script%20%22https%3A%2F%2Funpkg.com%2Freact%4017%2Fumd%2Freact.production.min.js%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22(example-1%2Fload-reagent-dom)%22))%0A%0A(defn%20load-reagent-dom%20%5B%5D%0A%20%20(load-script%20%22https%3A%2F%2Funpkg.com%2Freact-dom%4017%2Fumd%2Freact-dom.production.min.js%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22(example-1%2Fload-scittle-reagent)%22))%0A%0A(defn%20load-scittle-reagent%20%5B%5D%0A%20%20(load-script%20%22https%3A%2F%2Fcdn.jsdelivr.net%2Fnpm%2Fscittle%400.6.17%2Fdist%2Fscittle.reagent.js%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22(example-1%2Fmain)%22))%0A%0A(defn%20page%20%5B%5D%0A%20%20%22Hello%20world!%22)%0A%0A(def%20loader%20%22%0A%20%20(require%20%27%5Breagent.core%20%3Aas%20r%5D)%0A%20%20(require%20%27%5Breagent.dom%20%3Aas%20rdom%5D)%0A%20%20(rdom%2Frender%20%5Bpage%5D%20app)%0A%22)%0A%0A(defn%20main%20%5B%5D%0A%20%20(js%2Fscittle.core.eval_string%20loader))%0A%0A(load-reagent)%0A%20 and you see "Hello world!"?

henrik42 2024-07-18T11:19:11.833709Z

I just see a blank page.

henrik42 2024-07-18T11:24:33.734889Z

Ah sorry. You are right, when I do a "click" it adds "Hello world!" to the top. I was doing a ctrl-shift-click because I wanted to open the app in a new tab. And in that case I just see a blank page.

borkdude 2024-07-18T11:37:18.284919Z

you need to add it as a bookmarklet I think and then click it while being on the blank page

borkdude 2024-07-18T11:38:53.037199Z

with your gist, this works fine:

borkdude 2024-07-18T11:38:58.584249Z

(tested on chrome)

henrik42 2024-07-18T12:54:31.001829Z

OK, got it. The bookmark works as long as I'm on a page incl. about:blank. But I cannot ctrl-click on the bookmark to open a new page and run the bookmarklet in one jump. Thanks for your help!

borkdude 2024-08-05T07:45:25.655579Z

nice!

henrik42 2024-08-04T22:45:41.791109Z

@borkdude Been playing around with sci & scittle and came up https://gist.github.com/henrik42/885547a26ddf0bfacef4344bf128683f. Running the "Scittle Bookmarklet creator" as a bookmarklet. sci is just so much fun! Thanks a lot for that!