-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
82 lines (76 loc) · 2.58 KB
/
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
document.addEventListener('DOMContentLoaded', () => {
chrome.tabs.query({active: true, currentWindow: true}, (tabs) => {
chrome.scripting.executeScript({
target: {tabId: tabs[0].id},
function: scrollWithShadowAnimation
});
});
});
function scrollWithShadowAnimation() {
if (window.shadowAnimationRunning) return;
window.shadowAnimationRunning = true;
const style = document.createElement('style');
style.innerHTML = `
.shadow-animation-overlay {
position: fixed;
top: -20px;
left: -20px;
width: calc(100% + 40px);
height: calc(100% + 40px);
pointer-events: none;
z-index: 9999;
box-shadow:
0 0 0 0 rgba(234, 47, 237, 0.5) inset,
0 0 0 0 rgba(0, 122, 255, 0.3) inset,
0 0 0 0 rgba(0, 122, 255, 0.1) inset;
animation: shadowGlow 2s infinite;
}
@keyframes shadowGlow {
0% {
box-shadow:
0 0 30px 20px rgba(234, 47, 237, 0.3) inset,
0 0 60px 40px rgba(0, 122, 255, 0.2) inset,
0 0 90px 50px rgba(0, 122, 255, 0.1) inset;
}
50% {
box-shadow:
0 0 30px 20px rgba(234, 47, 237, 1) inset,
0 0 60px 40px rgba(0, 122, 255, 0.3) inset,
0 0 90px 50px rgba(0, 122, 255, 0.2) inset;
}
100% {
box-shadow:
0 0 30px 20px rgba(234, 47, 237, 0.3) inset,
0 0 60px 40px rgba(0, 122, 255, 0.2) inset,
0 0 90px 50px rgba(0, 122, 255, 0.1) inset;
}
}
`;
document.head.appendChild(style);
const overlay = document.createElement('div');
overlay.classList.add('shadow-animation-overlay');
document.body.appendChild(overlay);
const threadContainer = document.querySelector('.p-flexpane__body .c-scrollbar__hider');
if (threadContainer) {
let lastScrollTop = threadContainer.scrollTop;
threadContainer.addEventListener('scroll', () => {
if (threadContainer.scrollTop !== lastScrollTop) {
console.log('ユーザーによるスクロールが検出されました。自動スクロールを停止します。');
clearInterval(intervalId);
overlay.remove();
style.remove();
window.shadowAnimationRunning = false;
}
});
const intervalId = setInterval(() => {
if (!window.shadowAnimationRunning) return;
threadContainer.scrollTop = threadContainer.scrollHeight;
lastScrollTop = threadContainer.scrollTop;
}, 100);
} else {
console.log('Slackのスレッドが見つかりませんでした。');
overlay.remove();
style.remove();
window.shadowAnimationRunning = false;
}
}