Skip to content

Metadata Block Parsing & Implementing #23

@stuartpb

Description

@stuartpb

It looks like BabelExt is missing functions for handling userscripts the way GreaseMonkey did.

The way I see it, this could best be accomplished, in an appropriately DIY fashion, by providing:

  • A function that takes a string (or something that implements its interface like Node's Buffer), finds the first metadata block (or all? pretty sure successive blocks are ignored), and returns a JS Object with the "@keys" converted to properties of the object, with strings as values (or arrays of strings when there is more than one instance of a key such as @require). This function can then be used by eg. a build script that reads all files, then outputs a "userscripts.json" that will be read in at runtime to determine which scripts to include.
  • A function for reading the extension's files (per the above note about using a "userscripts.json").
  • A function that takes an object with keys of userscript filenames, and values of the parsed metadata block objects, and then loads the userscripts based on their metadata. This includes per-browser functions (which could be surfaced to the BabelExt API) that add a script (from the extension or from the Internet via @require) in a new context (eg. XPCNativeWrapper in FF, with access to unsafeWindow) either before or after pageload. It can also insert https://github.com/honestbleeps/BabelExt/blob/master/lib/extension.js#L44-51 and/or extension API functions based on @grant.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions