-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
175 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,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 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;"; | ||
|
||
var nwmesag = "Sehr geehrter Herr/Frau "+verk+",\n\nIch interessiere mich für "+ware+". Und wollte fragen \n\nLiebe Grüße,\n"+kauf; | ||
// load saved text | ||
var nwmesag = ""; | ||
|
||
function afterLoadingText() { | ||
// replace vars | ||
nwmesag = nwmesag.replace("%verk%",verk).replace("%kauf%",kauf).replace("%ware%",ware); | ||
|
||
mess[0].style = nwstyle; | ||
mess[1].style = nwstyle; | ||
// prepare msg fields | ||
mess[0].style = nwstyle; | ||
mess[1].style = nwstyle; | ||
mess[0].value = nwmesag; | ||
mess[1].value = nwmesag; | ||
} | ||
|
||
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(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
body { | ||
background: #f9f9f9; | ||
font-size: 15px; | ||
border: 2px solid green; | ||
border-radius: 4px; | ||
font-family:Verdana, Geneva, sans-serif; | ||
overflow: hidden; | ||
margin: 15px; | ||
} | ||
|
||
h1 { | ||
width: 100%; | ||
margin: 0 0 10px 0; | ||
background-color:green; | ||
} | ||
|
||
span { | ||
display:inline; | ||
} | ||
|
||
.saved { | ||
width: 20%; | ||
border: 2px solid green; | ||
border-radius: 4px; | ||
margin: 12px 10px 12px 2%; | ||
} | ||
|
||
.unsaved { | ||
width: 20%; | ||
border: 2px solid red; | ||
border-radius: 4px; | ||
margin: 12px 10px 12px 2%; | ||
} | ||
|
||
.container { | ||
display: block; | ||
position: relative; | ||
padding-left: 35px; | ||
margin: 0 0 12px 2%; | ||
cursor: pointer; | ||
-webkit-user-select: none; | ||
-moz-user-select: none; | ||
-ms-user-select: none; | ||
user-select: none; | ||
} | ||
|
||
.container input { | ||
position: absolute; | ||
opacity: 0; | ||
cursor: pointer; | ||
height: 0; | ||
width: 0; | ||
} | ||
|
||
.checkmark { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
height: 20px; | ||
width: 20px; | ||
background-color: #eee; | ||
} | ||
|
||
.container:hover input ~ .checkmark { | ||
background-color: #ccc; | ||
} | ||
|
||
.container input:checked ~ .checkmark { | ||
background-color: green; | ||
} | ||
|
||
.checkmark:after { | ||
content: ""; | ||
position: absolute; | ||
display: none; | ||
} | ||
|
||
.container input:checked ~ .checkmark:after { | ||
display: block; | ||
} | ||
|
||
.container .checkmark:after { | ||
left: 6px; | ||
top: 2px; | ||
width: 5px; | ||
height: 10px; | ||
border: solid white; | ||
border-width: 0 3px 3px 0; | ||
-webkit-transform: rotate(45deg); | ||
-ms-transform: rotate(45deg); | ||
transform: rotate(45deg); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>KAFI Options</title> | ||
<link rel="stylesheet" href="options.css"> | ||
<meta charset="UTF-8"> | ||
</head> | ||
<body> | ||
<h1> Options</h1> | ||
</h1> | ||
<label class="container">Automatic text 2 add in msg field newline(\n), use %verk% for the seller name, %kauf% for the buyer name (you) and %vware% for the product name.<br>When left blank it fills with the default text. | ||
<br> | ||
<span><textarea type="text" class="saved" id="text" rows="10" style="width:80%;"></textarea></span> | ||
</label> | ||
<script src="options.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// 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%"; | ||
|
||
//save the options | ||
function save_options() { | ||
let text = document.querySelector('#text').value; | ||
if(text == ""){text = defaultText;} // reset text if empty | ||
chrome.storage.sync.set({ | ||
text: text | ||
}, function () { | ||
var text = document.getElementById("text"); | ||
text.className = "unsaved"; | ||
setTimeout(function () { | ||
text.className = "saved"; // maybe rebuild this function | ||
}, 250); | ||
}); | ||
} | ||
|
||
function restore_options() { | ||
chrome.storage.sync.get({text: defaultText}, function (items) { | ||
document.querySelector('#text').value = items.text; | ||
}); | ||
} | ||
|
||
//load the options | ||
document.addEventListener('DOMContentLoaded', restore_options); | ||
|
||
document.querySelector("#text").addEventListener("change", function () { | ||
save_options(); | ||
}, false); |