惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The GitHub Blog
The GitHub Blog
P
Privacy International News Feed
博客园_首页
Hugging Face - Blog
Hugging Face - Blog
A
About on SuperTechFans
量子位
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
雷峰网
雷峰网
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
V
V2EX
Recent Announcements
Recent Announcements
博客园 - 叶小钗
B
Blog RSS Feed
Apple Machine Learning Research
Apple Machine Learning Research
Microsoft Azure Blog
Microsoft Azure Blog
H
Help Net Security
C
Check Point Blog
N
Netflix TechBlog - Medium
Y
Y Combinator Blog
P
Proofpoint News Feed
T
The Blog of Author Tim Ferriss
D
DataBreaches.Net
月光博客
月光博客
Engineering at Meta
Engineering at Meta
博客园 - 【当耐特】
Martin Fowler
Martin Fowler
小众软件
小众软件
博客园 - 司徒正美
大猫的无限游戏
大猫的无限游戏
爱范儿
爱范儿
M
MIT News - Artificial intelligence
G
Google Developers Blog
MyScale Blog
MyScale Blog
Google DeepMind News
Google DeepMind News
D
Docker
有赞技术团队
有赞技术团队
H
Hackread – Cybersecurity News, Data Breaches, AI and More
V
Visual Studio Blog
Recorded Future
Recorded Future
I
InfoQ
T
Tailwind CSS Blog
MongoDB | Blog
MongoDB | Blog
人人都是产品经理
人人都是产品经理
云风的 BLOG
云风的 BLOG
美团技术团队
Vercel News
Vercel News
GbyAI
GbyAI
aimingoo的专栏
aimingoo的专栏
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
WordPress大学
WordPress大学

蛇年大吉

通过json生成talk-card | 蛇年大吉 通过json生成site-card | 蛇年大吉 通过json生成图片集 | 蛇年大吉 如何更新主题 | 蛇年大吉 netlify部署博客 | 蛇年大吉 增加获取图片标签 | 蛇年大吉 关于我页面写法 | 蛇年大吉 markdown样式优化 | 蛇年大吉 音乐播放器失效问题 | 蛇年大吉 新增酷炫按钮和预加载动画 | 蛇年大吉 首页github日历 | 蛇年大吉 轮播-swiper | 蛇年大吉 主题config配置项简介 | 蛇年大吉 制作简历(关于我)和404页面 | 蛇年大吉 自定义live2d | 蛇年大吉 自定义css之导航和页脚高斯模糊 | 蛇年大吉 自定义css之头部图片透明 | 蛇年大吉 给bamboo添加动态背景 | 蛇年大吉 给bamboo添加右上角梅花 | 蛇年大吉
首页添加弹幕 | 蛇年大吉
作者: YuAng · 2022-07-15 · via 蛇年大吉

上面引入的三个文件中, 有一个叫做/danmu/index.js的文件需要我们自己编写和创建的:
在根目录的source文件夹下创建danmu/index.js文件:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86


function renderData() {
let homeDanmuArr = [
{
img: "http://120.48.121.186/medias/logo.png",
info: "欢迎访问bamboo主题",
href: "https://yuang01.github.io/",
close: true,
speed: 15,
color: "#42b983",
old_ie_color: "#000000",
},
{
img: "http://120.48.121.186/medias/logo.png",
info: "国内可以访问http://120.48.121.186",
href: "http://120.48.121.186",
close: true,
speed: 15,
color: "blue",
old_ie_color: "#000000",
},
{
img: "http://120.48.121.186/medias/logo.png",
info: "国内可以访问http://120.48.121.186",
href: "http://120.48.121.186",
close: true,
speed: 12,
color: "red",
old_ie_color: "#000000",
},
];

for (var i = 0; i < 20; i++) {
homeDanmuArr[i] = homeDanmuArr[i] ? homeDanmuArr[i] : {speed: 12};
}
return homeDanmuArr;
}
function homeDanmuFn() {
let data = renderData();

let homelooper_time = 3 * 1000;
let items = data;

let total = data.length;

let run_once = true;

let index = 0;

barrager();
async function barrager() {
if (run_once) {

homelooper = setInterval(barrager, homelooper_time);
run_once = false;
}

const responseImg = await fetch('https://api.btstu.cn/sjtx/api.php?lx=c1&format=json');
const imgJson = await responseImg.json();
const responseInfo = await fetch('https://api.vvhan.com/api/ian?type=json');
const infoJson = await responseInfo.json();

items[index].img = imgJson.imgurl;

index > 2 && (items[index].info = infoJson.ishan);
$("body").barrager(items[index]);

index++;

if (index == total) {
clearInterval(homelooper);
return false;
}
}
}
homeDanmuFn();

document.addEventListener('pjax:send', function (e) {
if (homelooper) {
clearInterval(homelooper);
$.fn.barrager.removeAll();
}
})