monkey-box

A simple ui framework for monkey script

As of 2018-06-02. See the latest version.

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greasyfork.org/scripts/368779/602185/monkey-box.js

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

Author
bramblex
Version
0.0.1
Created
2018-05-30
Updated
2018-06-02
Size
6.87 KB
License
MIT

MonkeyBox

基于 vue 的简易有猴子 ui 框架

使用方法

  1. 首先创建一个油猴子脚本,并且添加如下代码进入 metadata
// @require https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.16/vue.min.js
// @require https://greasyfork.org/scripts/368779-monkey-box/code/monkey-box.js
  1. MonkeyBox.addBox(id: string, vue: VueComponet) 在 MonkeyBox 里添加组件
MonkeyBox.addBox('hellobox', {
    // 自动保存 data (可选)
    autosave: 'local' | 'global' ,

    // 自动转换成带 scope 的css (可选)
    style: `
        button {
            color: red;
        }
    `,

    // vue 模板
    template: '<button @click="sayHello">{{ text }}</button>', 

    // 数据模型
    data: {
        msg: 'hello'
    },

    // 定义方法
    methods: {
        sayHello() {
            alert('hello')
        },

        testApi() {
        // 绑在 vm 中的 API
            this.loadGlobalData()
            this.loadLocalData()
            this.saveGlobalData(data)
            this.saveLocalData(data)
            this.clearLocalData()
            this.clearGlobalData()
        }
    }

})