Add-js/css

给浏览器添加手动引入外部js及css的两个方法,方便临时引入外部文件调试页面

Mint 2019.09.11.. Lásd a legutóbbi verzió

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 or Violentmonkey 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!)

// ==UserScript==
// @name         Add-js/css
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  给浏览器添加手动引入外部js及css的两个方法,方便临时引入外部文件调试页面
// @author       Sean
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 加载js
    function addjs(src) {
        var head = document.querySelector('head');
        var script = document.createElement('script');
        script.src = src+'';
        script.type = 'text/javascript';
        head.appendChild(script);
        return '外部js注入成功' + script.src;
    }
    // 加载css
    function addcss(href) {
        var head = document.querySelector('head');
        var link = document.createElement('link');
        link.href = href+'';
        link.rel = 'stylesheet';
        link.type = 'text/css';
        head.appendChild(link)
        return '外部css注入成功' + link.href;
    }
    // 注入浏览器window对象
    window.addjs = addjs;
    window.addcss = addcss;
})();