All Projects ā†’ lucidd ā†’ Scala Js Chrome

lucidd / Scala Js Chrome

Licence: mit
ScalaJS bindings for Chrome Extention/App and ChromeOS APIs

Programming Languages

scala
5932 projects
scalajs
39 projects

Projects that are alternatives of or similar to Scala Js Chrome

Vbookmarks
A successor of Neat Bookmarks.
Stars: āœ­ 61 (-16.44%)
Mutual labels:  chrome-extension
Enhanced Github
šŸš€ Browser extension to display size of each file, download link and copy file contents directly to the clipboard
Stars: āœ­ 1,146 (+1469.86%)
Mutual labels:  chrome-extension
Wpintel
Chrome extension designed for WordPress Vulnerability Scanning and information gathering!
Stars: āœ­ 70 (-4.11%)
Mutual labels:  chrome-extension
Ymc
Manage Yandex.Music from any macOS window
Stars: āœ­ 62 (-15.07%)
Mutual labels:  chrome-extension
Professional Codes Reader
Browse the web like a professional programmer!
Stars: āœ­ 63 (-13.7%)
Mutual labels:  chrome-extension
Web Bluetooth Polyfill
Windows 10 Web Bluetooth Polyfill
Stars: āœ­ 68 (-6.85%)
Mutual labels:  chrome-extension
One Click Extensions Manager
a simple chrome extension to manage chrome extension
Stars: āœ­ 61 (-16.44%)
Mutual labels:  chrome-extension
Chrome Zeroclickinfo
Chrome Extension using the DuckDuckGo Zero-click Info API
Stars: āœ­ 72 (-1.37%)
Mutual labels:  chrome-extension
Devtwitter
Bringing dev.to headlines to your Twitter browsing experience.
Stars: āœ­ 66 (-9.59%)
Mutual labels:  chrome-extension
Go Search Extension
The ultimate search extension for Golang
Stars: āœ­ 69 (-5.48%)
Mutual labels:  chrome-extension
Insta Downloader Extension
A browser extension that injects download buttons ā¬‡ļø for media on Instagram Web
Stars: āœ­ 63 (-13.7%)
Mutual labels:  chrome-extension
Ore
Repository software for Sponge plugins and Forge mods
Stars: āœ­ 63 (-13.7%)
Mutual labels:  sbt
Loungedestroyer
Chrome extension for CS:GO Lounge and DOTA2 Lounge
Stars: āœ­ 69 (-5.48%)
Mutual labels:  chrome-extension
Ccfrank4dblp
Displays the China Computer Federation (CCF) recommended rank of international conferences and journals in the dblp and Google Scholar search results.
Stars: āœ­ 62 (-15.07%)
Mutual labels:  chrome-extension
Github Contribution Color Graph
Change colors of contribution graph in GitHub.
Stars: āœ­ 70 (-4.11%)
Mutual labels:  chrome-extension
Scala Native.g8
Giter8 template for a minimal project that uses Scala Native.
Stars: āœ­ 61 (-16.44%)
Mutual labels:  sbt
Awsconsolerecorder
Records actions made in the AWS Management Console and outputs the equivalent CLI/SDK commands and CloudFormation/Terraform templates.
Stars: āœ­ 1,152 (+1478.08%)
Mutual labels:  chrome-extension
Pakku.js
ę‹ÆꕑBē«™ēš„弹幕体éŖŒļ¼
Stars: āœ­ 1,182 (+1519.18%)
Mutual labels:  chrome-extension
Pade
PƠdƩ (Yoruba word for Meet) is a browser extension (Chrome/Edge) based unified communications desktop client for Openfire.
Stars: āœ­ 72 (-1.37%)
Mutual labels:  chrome-extension
Fauxbar
An alternative to Chrome's Omnibox.
Stars: āœ­ 69 (-5.48%)
Mutual labels:  chrome-extension

Chrome for Scala.js Build Status Gitter Latest version Javadocs

The goal of this project is to provide an easy and typesafe way to create Chrome apps and extensions in Scala using the Scala.js project.

Chrome API bindings

The bindings provide access to the Chrome app and extension APIs. There are two levels for each API. One that provides the raw JavaScript bindings and a second one which wraps the raw API in a more Scala idiomatic way.

The package structure is similar to the original JavaScript API.

// original JavaScript
chrome.system.cpu.getInfo(function(info){
  if (chrome.runtime.lastError === undefined) {
    console.log(info);
  } else {
    console.log("ohoh something went wrong!");
  }
});
// raw bindings
chrome.system.cpu.bindings.CPU.getInfo((info: CPUInfo) => {
    if (chrome.runtime.bindings.Runtime.lastError.isEmpty) {
        println(info)
    } else {
        println("ohoh something went wrong!")
    }
})

// Scala idiomatic way using Future
chrome.system.cpu.CPU.getInfo.onComplete {
  case Success(info) => println(info)
  case Failure(error) => println("ohoh something went wrong!")
}

The Scala idiomatic binding provides the following general changes:

  • Futures instead of callbacks
  • Error handling using types like Future / Try instead of global error variable.
  • Using Option for things that may or may not be defined.

SBT Plugin

The job of the SBT plugin is to help with common tasks for developing Chrome apps/extensions. It also provides a way to configure your app/extension in your SBT file and automatically generate the manifest file.

  • chromePackage will create a ZIP file you can upload to the Chrome Web Store.
  • chromeUnpackedOpt (or chromeUnpackedFast) will build your projects with (or without) optimizations enabled. The output will be in target/chrome/unpacked-opt (or target/chrome/unpacked-fast) and can be loaded by Chrome as an unpacked extension/app.

Getting Started

Add this to your project/plugins.sbt:

addSbtPlugin("net.lullabyte" % "sbt-chrome-plugin" % "0.5.0")

Add this to your project dependencies:

"net.lullabyte" %%% "scala-js-chrome" % "0.5.0"

with scalajs-bundler

to use the <project-name>-f{ast,ull}opt-bundle.js generated by scalajs-bundler add the following to your build.sbt:

fastOptJsLib := Attributed.blank((webpack in (Compile, fastOptJS)).value.head)
fullOptJsLib := Attributed.blank((webpack in (Compile, fullOptJS)).value.head)

NOTE: if code seems to be executing duplicate times unintentionally, try removing these lines from the project's build.sbt

scalaJSUseMainModuleInitializer := true
scalaJSUseMainModuleInitializer in Test := false

Creating a basic Window

import chrome.app.runtime.bindings.LaunchData
import chrome.app.window.Window
import utils.ChromeApp

import scalajs.concurrent.JSExecutionContext.Implicits.queue

object ChromeAppExample extends ChromeApp {

  override def onLaunched(launchData: LaunchData): Unit = {
    println("hello world from scala!")
    Window.create("assets/html/App.html").foreach { window =>
      /**
         Access to the document of the newly created window.
         From here you can change the HTML of the window with whatever
         library you want to use.
      */
      window.contentWindow.document
    }
  }

}

For a more complete example see chrome-system-monitor and scala-js-chrome examples.

UI Libraries

There are already multiple libraries to manipulate HTML and build your UI available for Scala.js:

Known Issues

In Chrome apps and extensions there are multiple places where you can run JavaScript. Normally you split your logic into different files and load them into whatever context they need to run. Since Scala.js compiles your whole project into one big file all contexts need to load this big file with all the logic even if they only need a small subset. This can cause your app you use more memory then it need to. In some cases this can be worked around for example the a background page can manipulate the DOM of an App window so you don't need any JavaScript at all in the window itself.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].