Giter Club home page Giter Club logo

chouten-modules's Introduction

Note

This repository is a platform for user-generated content, and I do not host or control the specific files shared here. If you believe there is a copyright infringement, please direct your notice to the actual host or provider of the content. Thank you for your understanding.

Structure of the module

├── Home
│   └── code.js
├── Info
│   └── code.js
├── Media
│   └── code.js
├── Search
│   └── code.js
├── metadata.json
└── icon.png

Structure of metadata.json

{
    "id": String (Should be a UUID) (e.g. "078efc22-3314-11ee-be56-0242ac120002"),
    "type": "Video" or "Book" or "Text" (e.g. "Video"),
    "subtypes": String Array (e.g. ["anime"]),
    "name": String (e.g. "Aniwatch.to"),
    "version": String (e.g. "0.3.0"),
    "formatVersion": Number (e.g. 1),
    "updateUrl": String (e.g. "https://raw.githubusercontent.com/adolar0042/MyModule/main/module.json"),
    "general": {
      "author": String (e.g. "Inumaki"),
      "description": String (e.g. "A module to get the data from aniwatch.to"),
      "lang": String Array (e.g. ["en-US"]),
      "baseURL": String (e.g. "https://mymodule.com"),
      "bgColor":  String (e.g. "#ffcb3d"),
      "fgColor": String (e.g. "#000000")
    }
}

Structure of code.js

You can put any functions in code.js, but there are some functions that the js file already has access to:

  1. A function named logic: The logic function is an async function, that will receive a parameter which will be a JSON Object. Refer to the demo code to see when this is relevant. (todo)

    • Signature: logic(params: { [key: string]: string }): Promise<void>
    • Note: This function will be automatically called by the app, so make sure not to invoke it any where.
  2. To send HTTP requests with headers call the sendRequest function with the parameters url and headers:

    • Signature: sendRequest(url: string, headers: { [key: string]: string }): Promise<string>
    • Example: If you wanted to send a request to https://www.example.com with the header {referer: "https://www.example.com"}, you'd run:
      • await sendRequest("https://www.example.com", {referer: "https://www.example.com"})
  3. To load a js in a <script> tag, loadScript can be used. This will load the script to the DOM.

    • Signature: loadScript(url: string): Promise<void>
    • Example: if you wanted to load CryptoJS, you'd run:
      • await loadScript("https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js");
  4. To send the result back to the app, sendResult should be used. It may be called multiple times from the same js file (see: Info/code.js)

    • Signature: sendResult(result: string, last: boolean = false): Promise<void>;
    • Example: Run sendResult(JSON.stringify(result)) to send the result.
    • Note: The type of result varies. Refer to the demo code to see what type it should be of.
    • Note The last argument is used to tell that it's safe for the app to close the webview.

Building Modules

To build modules, simply run make build-module in the respective folder. If you don't have jq installed, you can run brew install jq or choco install jq on MacOS.

chouten-modules's People

Contributors

bilnaa avatar eltik avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.