-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
58 lines (58 loc) · 2.18 KB
/
popup.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
// config = {
// url: 'http://d838-77-111-227-3.ngrok.io/request'
//
// }
//
//
// document.addEventListener('DOMContentLoaded', () => {
// chrome.tabs.query({active: true, lastFocusedWindow: true}, tabs => {
// let url = tabs[0].url; // get the URL of the currently open tab
// if (url.startsWith("chrome://")) return;
// alert("testing");
// console.log("not a chrome tab");
// if (!url.contains("youtube")) {
// return;
// }
// fetch(url).then((r) => r.text().then(content => {
// // post the content of the webpage to the API
// console.log("sending data to API")
//
// postData(config.url, {url: url, content: "YouTube video"}).then();
// })).catch(error => {
// console.log(error);
// // post the URL to the API if we can't get the pages content.
// postData(config.url, {url: url}).then();
// });
// });
// });
//
//
// function check_if_bad(html) {
// if (html.contains("roblox")) {
// return true
// } else {
// return false
// }
// }
//
//
//
//
// // function to post data to an endpoint thanks stackoverflow xoxoxo
// async function postData(url = '', data = {}) {
// // Default options are marked with *
// const response = await fetch(url, {
// method: 'POST', // *GET, POST, PUT, DELETE, etc.
// mode: 'cors', // no-cors, *cors, same-origin
// cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
// credentials: 'same-origin', // include, *same-origin, omit
// headers: {
// 'Content-Type': 'application/json'
// // 'Content-Type': 'application/x-www-form-urlencoded',
// },
// redirect: 'follow', // manual, *follow, error
// referrerPolicy: 'no-referrer', // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url
// body: JSON.stringify(data) // body data type must match "Content-Type" header
// });
// return response.json(); // parses JSON response into native JavaScript objects
// }