-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinjectme.js
36 lines (29 loc) · 1.29 KB
/
injectme.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
// default vals
var defaultText = "Sehr geehrter Herr/Frau %verk%,\n\nIch interessiere mich für %ware%. Und wollte fragen \n\nLiebe Grüße,\n%kauf%";
// parse the elements to extract the necessary things
var verk = document.getElementsByClassName("text-bold text-bigger text-force-linebreak")[0].firstElementChild.innerHTML.replace("\n ","");
var ware = document.getElementById("viewad-title").innerHTML.replace("\n ","");
var kauf = document.getElementsByClassName("formcontrol viewad-contact-contactName")[0].value;
var mess = document.getElementsByClassName("viewad-contact-message");
verk = verk[0].toUpperCase() + verk.substring(1,verk.length);
var nwstyle = "margin-top: 0px; margin-bottom: 0px; height: 200px;";
// load saved text
var nwmesag = "";
function afterLoadingText() {
// replace vars
nwmesag = nwmesag.replace("%verk%",verk).replace("%kauf%",kauf).replace("%ware%",ware);
// prepare msg fields
mess[0].style = nwstyle;
mess[1].style = nwstyle;
mess[0].value = nwmesag;
mess[1].value = nwmesag;
}
// load saved text
chrome.storage.sync.get(null, function (items) {
if(items.text != undefined){
nwmesag = items.text;
} else {
nwmesag = defaultText;
}
afterLoadingText();
});