-
Notifications
You must be signed in to change notification settings - Fork 2
/
content.js
63 lines (51 loc) · 1.71 KB
/
content.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
/* This runs after a web page loads */
/* Brainstorming space:
MVP scope:
- when visiting a page in list, load the custom page with a mindfulness reminder message (eg "take a deep breath...")
- unlock page in 5 minutes. this applies to any website on the list
- then user can access it for 30 minutes. this applies to any website on the list
- script resets
name the extension "minefulness" as a play on word of "mindfulness"
TODO: look at the extension that tracks twitter visits. how is it persisting the visit count?
*/
const websiteList = [
"www.4chan.org",
"www.9gag.com",
"www.facebook.com",
"www.instagram.com",
"www.linkedin.com",
"www.myspace.com",
"www.reddit.com",
"www.snapchat.com",
"www.tumblr.com",
"www.twitter.com",
"www.tiktok.com",
"www.youtube.com",
"www.pinterest.com",
];
function ifCurrentWebsiteInList(websiteList) {
// get the current website's URL
let currentUrl = window.location.hostname;
// if URL doesn't include subdomain "www", add it
if (currentUrl.indexOf("www.") === -1) {
currentUrl = "www." + currentUrl
};
// loop through the list of websites and check if the current website's URL matches any of them
for (let i = 0; i < websiteList.length; i++) {
if (currentUrl === websiteList[i]) {
return true;
}
}
return false;
};
if (ifCurrentWebsiteInList(websiteList)) {
// replace content of page
document.querySelector("body").innerHTML = `
<br><br><br><br><br>
<p id="message">
Take a deep breath.
</p>
`;
// set bg color to black
document.querySelector("body").setAttribute('style', 'background-color: #000000 !important');
};