Skip to content

Commit 067ee8b

Browse files
committedAug 14, 2023
initial commit
1 parent dcb6743 commit 067ee8b

10 files changed

+165
-0
lines changed
 

‎README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ENS expiry to calender integration

‎images/icon-128.png

13.5 KB
Loading

‎images/icon-16.png

5.59 KB
Loading

‎images/icon-32.png

7.37 KB
Loading

‎images/icon-48.png

11 KB
Loading

‎manifest.json

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"manifest_version": 3,
3+
"name": "Ens expiry",
4+
"version": "1.0",
5+
"description": "Add the expiry date of an ens domain to calender.",
6+
"action": {
7+
"default_popup": "popup/popup.html",
8+
"default_icon": "images/icon-16.png"
9+
},
10+
"icons": {
11+
"16": "images/icon-16.png",
12+
"32": "images/icon-32.png",
13+
"48": "images/icon-48.png",
14+
"128": "images/icon-128.png"
15+
},
16+
"content_scripts": [
17+
{
18+
"js": ["scripts/content.js"],
19+
"matches": [
20+
"https://app.ens.domains/*"
21+
]
22+
}
23+
],
24+
"web_accessible_resources": [{
25+
"resources": ["popup/addtocalender.js"],
26+
"matches": [
27+
"https://app.ens.domains/*"
28+
]
29+
}],
30+
"content_security_policy": {
31+
"extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'self';"
32+
}
33+
}
34+

‎popup/addtocalender.js

+40
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎popup/popup.html

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<html>
2+
<body>
3+
<h1>Hello Extensions</h1>
4+
<script src="addtocalender.js"></script>
5+
<script src="popup.js"></script>
6+
<add-to-calendar-button
7+
name="Title"
8+
options="Google"
9+
location="World Wide Web"
10+
startDate="2023-08-16"
11+
endDate="2023-08-16"
12+
startTime="10:15"
13+
endTime="23:30"
14+
timeZone="America/Los_Angeles"
15+
></add-to-calendar-button>
16+
</body>
17+
</html>

‎popup/popup.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Update the relevant fields with the new data.
2+
const setDOMInfo = info => {
3+
document.getElementById('total').textContent = info.total;
4+
document.getElementById('inputs').textContent = info.inputs;
5+
document.getElementById('buttons').textContent = info.buttons;
6+
};
7+
8+
// Once the DOM is ready...
9+
window.addEventListener('DOMContentLoaded', () => {
10+
// ...query for the active tab...
11+
chrome.tabs.query({
12+
active: true,
13+
currentWindow: true
14+
}, tabs => {
15+
// ...and send a request for the DOM info...
16+
chrome.tabs.sendMessage(
17+
tabs[0].id,
18+
{from: 'popup', subject: 'DOMInfo'},
19+
// ...also specifying a callback to be called
20+
// from the receiving end (content script).
21+
setDOMInfo);
22+
});
23+
});
24+

‎scripts/content.js

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
const article = document.querySelector("button[data-testid='owner-profile-button-name.expiry']");
2+
if (article) {
3+
4+
// create add-to-calender button
5+
6+
let tit = document.querySelector("div[data-testid='profile-snippet-name']").textContent;
7+
let el = document.createElement('div');
8+
let startDate = article.getElementsByTagName('div')[3].textContent;
9+
10+
startDate = new Date(startDate);
11+
const offset = startDate.getTimezoneOffset();
12+
startDate = new Date(startDate.getTime() - (offset*60*1000)).toISOString().split('T')[0];
13+
14+
let title = `ENS expiry - ${tit}`;
15+
let butt = `<add-to-calendar-button name="${title}"
16+
options="Google"
17+
location="ENS domains"
18+
startDate=${startDate}
19+
endDate=${startDate}
20+
startTime="10:15"
21+
endTime="23:30"
22+
timeZone="America/Los_Angeles"></add-to-calendar-button>`;
23+
24+
el.innerHTML = butt;
25+
26+
27+
const articleNode = article.parentNode;
28+
// const butt = "<add-to-calendar-button name='Title' options='Google' location='World Wide Web' startDate='2023-08-16' endDate='2023-08-16' startTime='10:15' endTime='' timeZone='America/Los_Angeles'></add-to-calendar-button>"
29+
articleNode.insertAdjacentElement('afterend', el);
30+
31+
32+
var s = document.createElement('script');
33+
s.src = chrome.runtime.getURL('popup/addtocalender.js');
34+
s.onload = function() {
35+
this.remove();
36+
};
37+
(document.head || document.documentElement).appendChild(s);
38+
39+
40+
// chrome.runtime.sendMessage({
41+
// name: '',
42+
// location: '',
43+
// startDate: '',
44+
// endDate: '',
45+
// startTime: '',
46+
// endTime: '',
47+
// timeZone: ''
48+
// });
49+
}

0 commit comments

Comments
 (0)
Please sign in to comment.