您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Very Simple JS Notifications Library
当前为
此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/401626/795716/Notify%20Library.js
- /* **************
- Notify Library 1.1.2
- Developed by pizidavi
- Options:
- - text required
- - type optional
- - success
- - info/information
- - warn/warning
- - error
- - delay optional
- ************** */
- var Notify = function Notify(options) {
- var _this = this;
- if (!$('#notify').length) {
- $('body').append('<div id="notify"><style media="screen"> #notify { position: fixed; top: 20px; right: 25px; z-index: 9999; } #notify > div { display: none; position: relative; width: 300px; padding: .4em .8em; margin-bottom: .6em; border-radius: 2px; background-color: white; color: #2c3e50; font-size: 17px; cursor: pointer; transition: .4s; } </style></div>');
- }
- _this.options = options;
- _this.container = $('#notify');
- _this.template = $('<div><span></span></div>');
- if (!_this.options || typeof _this.options != 'object') {
- throw 'Options required';
- }
- if (!_this.options.text) {
- throw 'Options TEXT must not be empty';
- }
- if (_this.options.type) {
- var background = '';
- switch (_this.options.type) {
- case 'success':
- background = '#2ecc71';
- break;
- case 'info':
- case 'information':
- background = '#3498db';
- break;
- case 'warn':
- case 'warning':
- background = '#f9ca24';
- break;
- case 'error':
- background = '#e74c3c';
- break;
- default:
- throw 'Type not found';
- }
- if (background) {
- _this.template.css('background-color', background);
- _this.template.css('color', 'white');
- }
- }
- _this.id = 'noty_'+Math.random().toString(36).substring(2);
- _this.template.attr('id', _this.id);
- _this.template.find('span').text(_this.options.text);
- _this.template.css('right', -(300+parseInt(_this.container.css('right')))+'px');
- };
- Notify.prototype.show = function () {
- var _this = this;
- if (!_this.container.find('#'+_this.id).length) {
- _this.container.append(_this.template);
- }
- _this.template.css('display', 'block');
- _this.template.off('click').on('click', function() {
- _this.close();
- });
- setTimeout(function() {
- _this.template.css('right', '0');
- }, 100);
- if (_this.options.delay !== 0) {
- _this.closeTime = setTimeout(function() {
- _this.close();
- }, (_this.options.delay || 4500));
- }
- return _this;
- };
- Notify.prototype.close = function () {
- var _this = this;
- if (!_this.container.find('#'+_this.id).length) return;
- clearTimeout(_this.closeTime);
- _this.template.css('right', -(300+parseInt(_this.container.css('right')))+'px');
- setTimeout(function() {
- _this.template.remove();
- }, 500);
- return _this;
- };