Tampermonkey: 注入layui

Author Avatar
云璃 2019年08月06日

简介

使用 Tampermonkey 插件向网页注入 layui。

片段

// ==UserScript==
// @name         New Userscript
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @grant        none
// @require https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js
// ==/UserScript==

(function() {
    'use strict';
    // layui.js 需延迟加载,否则会报错。
    $.getScript("https://www.layuicdn.com/layui/layui.js")
    $("head").append("<link>");
    var css = $("head").children(":last");
    css.attr({
      rel: "stylesheet",
      type: "text/css",
      href: "https://www.layuicdn.com/layui/css/layui.css"
    });


    layui.use('layer', function(){
        var layer = layui.layer;
  
        layer.msg('hello');
    }); 
    // Your code here...
})();

鸣谢

bootcdn
layui 免费 cdn

本文链接:https://www.masterzc.cn/archives/108.html
本站使用「署名 4.0 国际」创作共享协议,可自由转载、引用,但需署名作者且注明文章出处

    墨染
    墨染  2019-08-16, 21:32

    给力,google 了半天。

Title - Artist
0:00