Add-js/css

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==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;
})();