Skip to content

Commit

Permalink
Add support for defining the content_scripts on the extension manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexITC committed Sep 29, 2019
1 parent 603740b commit 8495082
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
11 changes: 10 additions & 1 deletion sbt-plugin/src/main/scala/net/lullabyte/JsonCodecs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ object JsonCodecs {
)
}

implicit val contentScriptsEncoder = Encoder.instance[chrome.ContentScripts] { contentScripts =>
Json.obj(
("matches", Json.fromValues(contentScripts.matches.map(Json.fromString))),
("css", Json.fromValues(contentScripts.css.map(Json.fromString))),
("js", Json.fromValues(contentScripts.js.map(Json.fromString)))
)
}

implicit val actionEncoder = Encoder.instance[chrome.Commands.Action] { action =>
Json.obj(
("suggested_key", action.suggestedKey.asJson),
Expand Down Expand Up @@ -189,7 +197,8 @@ object JsonCodecs {
("omnibox", manifest.omnibox.asJson),
("options_ui", manifest.optionsUI.asJson),
("browser_action", manifest.browserAction.asJson),
("chrome_ui_overrides", manifest.chromeUIOverrides.asJson)
("chrome_ui_overrides", manifest.chromeUIOverrides.asJson),
("content_scripts", manifest.contentScripts.asJson)
)
Json.fromFields(
commonValues ++ extValues
Expand Down
7 changes: 7 additions & 0 deletions shared/src/main/scala/chrome/Manifest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ case class BrowserAction(
title: Option[String] = None,
popup: Option[String] = None
)

case class ContentScripts(
matches: List[String],
css: List[String],
js: List[String])

case class Bluetooth(
uuids: List[String] = Nil,
socket: Option[Boolean] = None,
Expand Down Expand Up @@ -103,4 +109,5 @@ trait ExtensionManifest extends chrome.Manifest {
val omnibox: Option[Omnibox] = None
val optionsUI: Option[OptionsUI] = None
val chromeUIOverrides: Option[ChromeUIOverrides] = None
val contentScripts: Option[ContentScripts] = None
}

0 comments on commit 8495082

Please sign in to comment.