-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathofferzen.js
30 lines (27 loc) · 932 Bytes
/
offerzen.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
console.log("Running!")
//Add the dino to the toolbar
function pollDOM() {
//Wait for the toolbar to appear on the page
const linkBox = document.querySelector('.referral-link');
if (linkBox) {
scrape_code();
//If ther box isn't there yet, try again later.
} else {
console.log("Polling");
setTimeout(pollDOM, 300); // try again in 300 milliseconds
}
}
pollDOM();
function scrape_code() {
var referralCodeString = document.querySelector('.referral-link').value;
var referralCode = referralCodeString.split("/").pop();
console.log(referralCode);
chrome.storage.sync.set({
referralCode: referralCode
}, function() {
// Update status to let user know options were saved.
setTimeout(function() {
window.alert(`Your OfferZen referral code ${referralCode} has been saved to Dino Referrer`);
}, 500); // Delay the alert by 500 milliseconds to give the page time to render.
});
}