Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Kevin Walter
@lucidd
I think this is a similar problem to projects that have a Scala server project which needs a scalajs client project as a ressource.
@kramer425 you should be able to have two projects in sbt and use the generated Resource mechanism to copy content script into the extension. Depending on this library in your content script should not be a problem as long as you dont use anything thats not availabe in the web page. scalajs will make sure to only include what you actually use so there should be no additional cost.
kramer425
@kramer425
Thanks Kevin I'll try that. Since I can specify which websites I want the content script to run on, do you think I would include a main in it as well?
Kevin Walter
@lucidd
i think it needs a main to run if you inject it into the website but you have to look at the content script documentation
kramer425
@kramer425
Ok thanks. Do you think in CodeInjectionOptions def apply(code: js.UndefOr[String] = js.undefined, could be changed to take a js.Any or js.Function so you can pass in scala code?
Kevin Walter
@lucidd
@kramer425 that would be cool but i don't think thats possible. Chrome wants a string of javascript there is no way around that. maybe it would be possible to use a macro to pass in a scala function and have it at compile time transformed into a string of javascript but i don't think its trivial.
Simone Robutti
@chobeat

Hello, I'm a scalajs newb (and not really skilled in JS either). I'm trying to create a chrome extension using scala-js-chrome

I got a general idea on how to work with the ChromeApp API and how to create windows but I would like to actually create an extension that listens to events in all the tabs. I saw how to do this in JS through CodeInjection. My problem is that, while the wrapper wraps the corresponding call "executeScript", I don't know how to pass the actual code to execute. The options available are through a string and through a filename. ( https://github.com/lucidd/scala-js-chrome/blob/master/bindings/src/main/scala/chrome/tabs/bindings/CodeInjectionOptions.scala )

In my newbiness I have no idea how to do so through scalajs

Kevin Walter
@lucidd
@chobeat there are multiple ways you could go about this. Chrome wants either javascript as a string or a file to inject. You could just inject a plain javascript file if you want but i guess thats not what you are looking for. Alternatively you could inject your extension script itself and have some check in the main for if its running in a web page or as extension and act accordingly. The third option is to setup a multiproject sbt build where you have your extension project and your inject script project and have the extension depend on the output of the inject script project as a resource.
Simone Robutti
@chobeat
@lucidd thank you very much. I'm not sure about how to go for the second option but I will try something. Otherwise the third option seems the cleanest and I will go for it
kramer425
@kramer425
@chobeat If you get the third option to work, please let me know!
@lucidd Thanks Kevin, didn't see your last response. Hopefully Simone makes progress with using multiprojects to write content scripts in scala
kramer425
@kramer425
Hey guys, I opened up an issue for adding support for content & popup scripts. In the meantime I made a repo with three different projects in it, and a shell script that compiles them and copies over the necessary files
kramer425
@kramer425
Has anyone used Runtime.sendMessage? Runtime.sendMessage(message = "hi") is giving me an error: Error in event handler for runtime.onMessage: Error: Invalid arguments to sendMessage. at $c_Lchrome_runtime_Runtime$.sendMessage__sjs_js_UndefOr__sjs_js_Any__sjs_js_UndefOr__sjs_js_UndefOr__V that's hard to parse
Jordan Gwyn
@emanresusername
@kramer425 ^^ idk if it's exactly the same, but i hit something similar might be worth specifying some of the other args to that method
kramer425
@kramer425
Good to know thanks! I went with chrome.runtime.bindings.Runtime.sendMessage which seems to work
Aleksandr Bezhan
@alexbezhan
Hey guys. Does scala-js-chrome plugin support source maps?
Yuriy Badalyantc
@LMnet
Hi everybody. What is the status of the project? I want to use it and contribute to it, but last commit was on June and project looks abandoned.
Jordan Gwyn
@emanresusername
:+1:
Kevin Walter
@lucidd
@OleksandrBezhan i currently don't have much time to work on the project so i only merge PRs and publish new versions occasionally. I hope i have more time for it in the future but no promises sorry.
sorry wrong guy. was meant fot @LMnet
Mathieu Prevel
@mprevel
@lucidd Hi. Do you think you will have time to merge current PRs ?
Kevin Walter
@lucidd
@mprevel i found some time to look at your PR and merge them. Thank you for those contributions :thumbsup:
Mathieu Prevel
@mprevel
@lucidd thanks :)
Mathieu Prevel
@mprevel
@lucidd I created 2 PRs. One for the source map support, another to update scala 2.11.11 to scala 2.11.12.
None of them passed the CI. It seems that Travis was unable to get some dependencies... and scala itself in both PRs. So this is clearly not a problem from the PRs themselves. I don't know if there is a way to request another build. I posted on the travis gitter expecting some help on this.
The scala update from 2.11.11 to 2.11.12 was almost only to check if the build will pass (but at least, this is done).
Mathieu Prevel
@mprevel
@lucidd I re-created the PRs and everything is ok. This was a temporary network issue
Mathieu Prevel
@mprevel
@lucidd thanks for the previous merge. Do you think you'll merge the PR on source maps ? If not what could be done to make it accepted ?
Erik LaBianca
@easel
Is there an up-to-date version of the set plugin published somewhere? Scaladex lists the Resolver.bintrayRepo("veinhorn", "maven") at version 0.5.8 but I'm not getting anything.
Erik LaBianca
@easel
I went ahead and published the latest head to bintray. Resolver.bintrayRepo("7thsense", "maven") and resolvers += Resolver.bintrayRepo("7thsense", "sbt-plugins") with version 2322da3adcc7be79da5db8ca4ab5c566fb2659e9.
David Portabella
@dportabella

I've downloaded this example: https://github.com/kramer425/scala-js-chrome-extension-example
and modified this file: ./chrome-background-example/src/main/scala/Main.scala
with this very simple program:

import scala.scalajs.js.JSApp

object Main extends JSApp {
  def main(): Unit = {
    println(chrome.app.window.Window.getAll.length)
  }
}

When I install the extension, the background program fails with:

main.js:1151 Uncaught TypeError: Cannot read property 'onBoundsChanged' of undefined
    at $c_Lchrome_app_window_Window$.init___ (main.js:1151)
    at $m_Lchrome_app_window_Window$ (main.js:1178)
    at $c_LMain$.main__V (main.js:1687)
    at main.js:2990
    at main.js:2991

Any idea?

Alexis Hernandez
@AlexITC
@dportabella I don't know about such example but https://github.com/AlexITC/chrome-scalajs-template uses this library and works
Alexis Hernandez
@AlexITC
for anyone interested, I have forked the repo to get support for scalajs 1.0.0, it seems to work until now but I'm still testing: https://github.com/AlexITC/scala-js-chrome/tree/scalajs-1.0.0