Code Monkey home page Code Monkey logo

tampermonkey-typescript's Introduction

油猴脚本脚手架

特性

  • TypeScript完全支持
  • Babel完全支持 使用目前主流的@babel/preset-env
  • 热更新部署 每次更新会自动同步到油猴中,不需要手动复制粘贴!

使用方式

clone本项目,然后执行npm install

开发

一个完整的油猴脚本格式如下

// ==UserScript==

// 这部分是头部区域,一般来说不会经常修改

// ==/UserScript==

// 这里是正文,也就是脚本的执行部分,是需要经常修改的
console.log('hello world')

头部区域

头部区域的开发是在header/index.ts,使用了typescript,这样会有IDE完全支持,而不是单纯的写几个注释

img

开发完毕后执行npm run build:header编译

正文

正文开发是在src/index.ts,在开发时,如果使用到GM_相关函数,有完整的声明支持:

img

热部署

1.先执行 npm run build 编译一次,编译结果为 dist/main.js

2.执行 npm run start:server 启动 http://localhost:7000服务

默认用户名/密码为derjanb / secret

在油猴中设置

img

3.点 + ,把第1步编译的结果dist/main.js粘贴进去 保存

img

img

img

4.执行 npm run sync,现在每次更新就会自动同步到油猴中了,不需要手动粘贴!

发布

执行 npm run build 编译最新的文件

备注

本项目中引用以下资源

tempermonkey.d.ts

server.js (有修改)

tampermonkey-typescript's People

Contributors

xcr1234 avatar ljn26 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.