Greasy Fork is available in English.

toast.js

coco-message TheWindRises-2 js toast

Este script não deve ser instalado diretamente. Este script é uma biblioteca de outros scripts para incluir com o diretório meta // @require https://update.greasyfork.org/scripts/426194/971661/toastjs.js

Autor
古海沉舟
Versão
0.0.1.20210918060446
Criado
09/05/2021
Atualizado
18/09/2021
Licença
N/A

attribution:
https://github.com/TheWindRises-2/coco-message/blob/main/README.md
original-script: https://github.com/TheWindRises-2/coco-message
original author:TheWindRises-2

copyright:
https://github.com/TheWindRises-2/coco-message/blob/main/LICENSE
MIT License

Copyright (c) 2021 TheWindRises--

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


更改了toast弹出的颜色

cocoMessage.config({
duration: 10000
})
function changeText(num) {
switch (num) {
case 0:
cocoMessage.info(1500, "这是一条消息", () => {
console.log("close");
});
break;
case 1:
let div1 = document.createElement('div');
div1.innerText = '这是一条成功的消息'
cocoMessage.success(div1);
break;
case 2:
cocoMessage.warning("需要手动关闭消息", 0);
break;
case 3:
cocoMessage.error("这是一条错误的消息", 3000);
break;
case 4:
let closeMsg = cocoMessage.loading(true);
setTimeout(() => {
closeMsg();
}, 4000);
break;
case 5:
cocoMessage.destroyAll();
break;
default:
break;
}
}