Add-js/css

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

11.09.2019 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

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