-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
112 lines (106 loc) · 3.12 KB
/
index.html
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html, body {
height: 100%;
perspective: 1000px;
}
.comment {
position: absolute;
white-space: nowrap;
font-size: 36pt;
font-family: sans-serif;
letter-spacing: 4px;
color: #F0F0F0;
text-shadow :
2px 2px 1px #000000,
-2px 2px 1px #000000,
2px -2px 1px #000000,
-2px -2px 1px #000000,
2px 0px 1px #000000,
0px 2px 1px #000000,
-2px 0px 1px #000000,
0px -2px 1px #000000;
}
</style>
</head>
<body>
<webview
src="https://tweetdeck.com"
preload="tweetdeck.js"
style="display: none;">
</webview>
<script>
const { ipcRenderer } = require('electron');
const webview = document.querySelector('webview');
const comments = [];
const fontSize = 30;
const speed = 2;
const startComment = (comment) => {
const commentLength = comment.textContent.length;
const intervalId = setInterval(frame, 10);
function frame() {
const top = comment.style.top;
const left = parseInt(comment.style.left, 10);
if (left+(commentLength*fontSize*2) < 0) {
document.body.removeChild(comment);
clearInterval(intervalId);
return;
} else {
comment.setAttribute("style", `top: ${top}; left: ${left - speed}px;`);
return;
}
}
}
const createComment = async (text) => {
const comment = document.createElement('div');
comment.className = 'comment';
// Make space upside and downside
let top = fontSize + parseInt(
Math.random() * (window.outerHeight - fontSize * 3),
10
);
const left = parseInt(window.outerWidth+(Math.random()*window.outerWidth), 10);
comment.setAttribute("style", `top: ${top}px; left: ${left}px`);
comment.textContent = text;
await document.body.appendChild(comment);
startComment(comment);
}
const main = (tweets) => {
tweets.forEach(tweet => {
if (!comments.includes(tweet)) {
comments.push(tweet);
createComment(tweet);
}
});
}
webview.addEventListener("ipc-message", (event) => {
switch (event.channel) {
case "getTweets":
if (!event.args[0].length) {
webview.setAttribute("style", "min-width: 800px; min-height:1200px");
ipcRenderer.send('twitterStatus', false);
} else {
webview.setAttribute("style", "display: none");
ipcRenderer.send('twitterStatus', true);
main(event.args[0]);
}
break;
}
})
setTimeout(()=>{
webview.send("getTweets");
setInterval(()=>{
webview.send("getTweets");
}, 300);
}, 5000);
</script>
</body>
</html>