Comments (13)
I have linked this issue to the official scalajs chat, unfortunately, I won't have time to look into it in the coming days.
from scala-js-chrome.
I have updated the issue description with what I think is going on.
What I'm trying to say: Sorry for the spam @AlexITC, I'm working on this issue and it's looking like I can figure this out without additional help.
I am closing this issue for now. The reason being: Knowing what I know now, I would not have bothered to open it in the first place.
I'm still glad I documented it all here because it might help others but for that the issue doesn't have to remain open.
If you want to be kept in the loop feel free to reopen it. I do hope that I'll find time to work more on this next weekend.
In any case, thanks for all your work on this sbt-plugin without which none of this would have been possible!
from scala-js-chrome.
Thanks for pointing out the template! I am, in fact, already using it. Saved me a ton of work and I'm not sure I'd have had the patience to piece these things together in my spare time.
In fact, code that shows how to execute JS on the "top" context so it can access the website's JS might be a nice additional thing to have in the template, don't you think? It's a common thing for extensions to, well, extend a website with functionality. I shall file a PR when I get that to work!
from scala-js-chrome.
In fact, code that shows how to execute JS on the "top" context so it can access the website's JS might be a nice additional thing to have in the template, don't you think? It's a common thing for extensions to, well, extend a website with functionality. I shall file a PR when I get that to work!
Actually, I have that code, in short:
- The active tab context injects a js file to the target website like
<script>...</script>
. - The injected script communicates to the active tab context through message passing
window.postMessage
- The active tab listens for messages from the injected script, replying to those through message passing.
Let me see if I can prepare simple code about this.
from scala-js-chrome.
@phdoerfler I have gathered most of the logic to do what you intend, there is a chance I missed some details because I didn't had time to test it, still, once the logic is fixed, you should be able to invoke window.injected.getInfo()
that the extension has access to: https://github.com/AlexITC/chrome-scalajs-template/tree/website-injection
It's been a long time since I have been planning to include this in the template, I'm willing to fix it but I won't likely have much time in the following days.
Let me know how it goes!
from scala-js-chrome.
I see. Yeah, docs and especially tests would be nice. However, I managed to find my way around in the code easy enough and I don't see why others wouldn't either. To get people started, I don't think it needs more than a simple "If you need to access a website's JS, take a look at com.alexitc.chromeapp.website.Runner#run()
". Of course, someone
Since you asked:
Basically, I'm adding veloviewer tiles to komoot so I can better plan my bike tours to uncover more of these tiles. Here's what it looks like at the moment:
Currently, I use the URL to find out longitude and latitude and zoom level as it does contain those parameters:
https://www.komoot.de/plan/@52.6163609,11.9610035,11.076z?sport=touringbicycle
This has two drawbacks, though: It isn't updated very often and it's only available when planning a new route. Editing an old route does not put this info in the URL.
A better approach would thus be to access the JS map object directly and that's exactly what this injection code allows me to do
Pain points:
I tried rebasing my changes on top of your changes but gave up due to the number of merge conflicts. I then tried manually copying the new code over but that didn't immediately work either so I'll instead just redo my changes by hand on top of the new template.
Side note:
There's, in fact, a similar extension available for Strava already.
If it weren't for this nice plugin and template I would likely not have bothered re-inventing the wheel for komoot.
But thanks to the template I gave it a shot and I quickly got to what you see in the screenshot. Much quicker than anticipated, actually, which was very motivating!
from scala-js-chrome.
I pushed a fix to the linking error, also, I have merged the code injection to master (AlexITC/chrome-scalajs-template@1522798), to my surprise, it worked at the first try in Firefox/Chrome.
Thanks!
from scala-js-chrome.
Thanks for the details, if you liked the plugin, be sure to check https://github.com/AlexITC/chrome-scalajs-template
from scala-js-chrome.
@AlexITC Alright, I finally had time to play around with it and it's looking great! I am actually able to access the website's JS. Thanks a lot!
I am a bit surprised by the sheer amount of code that you had to add in order to make this possible, but I can't argue with the results! I vote for merging this into the main branch asap.
from scala-js-chrome.
Oh, I had already forgot about this, it is nice to know that it worked!
Indeed, it is a lot of code and not-so-trivial logic, the reason is that this require communication between many different contexts, including the insecure one where the websites run, I guess you could likely reduce the code but I haven't tried.
I'm interested to get this into master but I haven't had to document it, also, it would be nice to be able to run tests for such behavior, my conclusion is that cypress/selenium are the way.
I have no idea what you are doing but feel free to keep posting your results as well as your paint points.
from scala-js-chrome.
Thanks for sharing, I'll try to run some manual tests and get this merged, good luck!
from scala-js-chrome.
I changed my mind and rebased my work on top of the injection branch. Now I get linker errors because of this line involving GUID and thus java.security.SecureRandom:
Fast optimizing /Users/phi/Documents/workspace/Scala/komootl/target/scala-2.13/komootl-fastopt
Referring to non-existent class java.security.SecureRandom
called from private java.util.UUID$.csprng$lzycompute()java.util.Random
called from private java.util.UUID$.csprng()java.util.Random
called from java.util.UUID$.randomUUID()java.util.UUID
called from static java.util.UUID.randomUUID()java.util.UUID
called from private io.doerfler.komootl.activetab.ActiveTabPublicAPI.processCommand(io.doerfler.komootl.activetab.models.Command)scala.concurrent.Future
This seems to be caused by this: scala-js/scala-js#4657
which states:
This means that code that was previously calling java.util.UUID.randomUUID() will now fail to link.
Indeed, adding: "org.scala-js" %%% "scalajs-java-securerandom" % "1.0.0"
to the libraryDependencies fixes the linking error.
from scala-js-chrome.
Thanks for letting me know, I merged the scala-steward's PR but never got back to add the securerandom library.
from scala-js-chrome.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scala-js-chrome.