eight04 / Embed-Me

An userscript to embed video, images from links.
MIT License
5 stars 3 forks source link

Embed Me!

An userscript to embed videos, images from anchor link.

Test page

Install the script and visit this page:
Demo page

Supported sites

Checkout the module folder. Contributions welcome!

Module

A module object should look like:

{
    name: "The module name",
    global: true,               // The module should work globally,
    domains: ["example.com"],   // or the module will only work on these domains.
    getPatterns: function() {
        // Return a list of regex object. Only matched urls will be sent to embed function.
        return [
            // ...
        ];
    },
    getEmbedFunction: function() {
        // Return an embedding function.
        //
        // Params:
        //   1...n  The capturing groups returned by regex pattern. n = groups.length.
        //   n+1    The url of the link.
        //   n+2    The text content of the link.
        //   n+3    The link itself.
        //   n+4    A replace function.
        //
        // Usually you can return new element back. If you have to replace element asynchronously,
        // send new element to replace function when you are finished.

        return function (url, text, node, replace) {
            // ...
        }
    }
}

Known issues


Some online embedding service

Changelog