Greasy Fork is available in English.

toast.js

coco-message TheWindRises-2 js toast

此脚本不应被直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.greasyfork.org/scripts/426194/971661/toastjs.js

脚本作者
古海沉舟(Eazou)
版本
0.0.1.20210918060446
创建日期
2021-05-09
最近更新
2021-09-18
许可证
暂无

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;
}
}