UI

界面库调用接口

Stan na 04-05-2018. Zobacz najnowsza wersja.

Ten skrypt nie powinien być instalowany bezpośrednio. Jest to biblioteka dla innych skyptów do włączenia dyrektywą meta // @require https://update.greatest.deepsurf.us/scripts/53536/281536/UI.js

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

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

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         UI
// @namespace    https://github.com/yeomanye
// @version      0.2.1
// @include      *://*
// @description  界面库调用接口
// @author       Ming Ye
// ==/UserScript==

(function(context) {
    var TIME_SHORT = 1000;
    var tipsCss = {
        position: 'fixed',
        padding: '20px',
        transform: 'translate(-50%,-50%)',
        'font-size': '18px',
        'z-index': 999,
        background: 'black',
        color: 'white'
    };
    var tipsCssStyle = genderStyle(tipsCss);
    function genderStyle(cssObj){
        var cssKeys = Object.keys(cssObj),cssVals = Object.values(cssObj);
        var styleStr = '';
        for(var i=0,len=cssKeys.length;i<len;i++){
            var key = cssKeys[i],val = cssVals[i];
            styleStr += key+': '+val+';'
        }
        return styleStr
    }
    context.showTips = function(msg, time) {
        var width = window.innerWidth,
            height = window.innerHeight;
        time = time ? time : TIME_SHORT;
        var divElm = document.createElement('div');
        divElm.innerText = msg;
        divElm.setAttribute('style', tipsCssStyle);
        divElm.style.top = height / 2 + 'px';
        divElm.style.left = width / 2 + 'px';
        document.body.appendChild(divElm);
        setTimeout(function() {
            divElm.parentNode.removeChild(divElm);
        }, time);
    };
})(window);