diff --git a/128.png b/128.png new file mode 100644 index 0000000..6071221 Binary files /dev/null and b/128.png differ diff --git a/128_50.png b/128_50.png new file mode 100644 index 0000000..915cda7 Binary files /dev/null and b/128_50.png differ diff --git a/16.png b/16.png new file mode 100644 index 0000000..038c4ee Binary files /dev/null and b/16.png differ diff --git a/32.png b/32.png new file mode 100644 index 0000000..279cb65 Binary files /dev/null and b/32.png differ diff --git a/48.png b/48.png new file mode 100644 index 0000000..e668ee9 Binary files /dev/null and b/48.png differ diff --git a/64.png b/64.png new file mode 100644 index 0000000..d6dfc26 Binary files /dev/null and b/64.png differ diff --git a/background.js b/background.js new file mode 100644 index 0000000..12d0c8e --- /dev/null +++ b/background.js @@ -0,0 +1,29 @@ +chrome.runtime.onMessage.addListener( + function(request, sender, sendResponse) + { + if (request.localstorage == "chz_subject") + { + chrome.storage.sync.get( + ['chz_subject'], + function(result) + { + sendResponse({chz_subject: result.chz_subject}); + } + ); + } + else if (request.localstorage == "chz_message") + { + chrome.storage.sync.get( + ['chz_message'], + function(result) + { + sendResponse({chz_message: result.chz_message}); + } + ); + } + else + { + sendResponse({}); + } + } +); \ No newline at end of file diff --git a/inject.js b/inject.js new file mode 100644 index 0000000..94482f9 --- /dev/null +++ b/inject.js @@ -0,0 +1,15 @@ +chrome.storage.sync.get( + [ + 'chz_bbs_subject', + 'chz_bbs_message' + ], + function(result) + { + let dom_subject = document.getElementsByName("subject")[0]; + let dom_message = document.getElementsByName("message")[0]; + + console.log(result.chz_bbs_subject); + if(result.chz_bbs_subject != undefined && dom_subject.value.length == 0) dom_subject.value = result.chz_bbs_subject; + if(result.chz_bbs_message != undefined && dom_message.value.length == 0) dom_message.value = result.chz_bbs_message; + } +); \ No newline at end of file diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..3b91aa5 --- /dev/null +++ b/manifest.json @@ -0,0 +1,28 @@ + { + "manifest_version": 2, + "name": "Chapatiz Textarea", + "description": "Cette extension permet de pré-remplir les messages sur les forums de Chapatiz (chapatiz.com/bbs).", + "version": "3.2", + "icons": { + "128": "128.png", + "64": "64.png", + "48": "48.png", + "32": "32.png", + "16": "16.png" + }, + "browser_action": { + "default_popup": "popup.html", + "default_icon": "128.png" + }, + "permissions": ["storage"], + "background": { + "scripts": ["background.js"], + "persistent": false + }, + "content_scripts": [ + { + "matches": ["https://www.chapatiz.com/bbs/posting.php*"], + "js": ["inject.js"] + } + ] + } \ No newline at end of file diff --git a/popup.css b/popup.css new file mode 100644 index 0000000..995aa82 --- /dev/null +++ b/popup.css @@ -0,0 +1,57 @@ +:root +{ + --primary: #0BACAA; + --secondary: #67E2ED; + --light: #FFFFFF; + --dark: #000000; + /* + --primary: #0BACAA; + --secondary: #67E2ED; + --light: #FFFFFF; + --dark: #0D1E20; +*/ +} +body +{ + background-color: var(--secondary); +} + +.form input, +.form button, +.form textarea +{ + display: block; + width: 300px; + padding: 6px; + margin: 5px; +} +.input +{ + border: 1px solid var(--primary); + color: var(--primary); + background-color: var(--light); + font-family: courier; +} +.btn +{ + background-color: var(--primary); + color: var(--light); + font-family: sans-serif; + + transition: background-color 0.5s, color 0.5s; +} +.btn:hover +{ + background-color: var(--light); + color: var(--primary); +} +.btn:active +{ + background-color: var(--secondary); + color: var(--dark); +} +.bg-128-50 +{ + background: url('128_50.png') no-repeat right bottom; + background-color: var(--light); +} \ No newline at end of file diff --git a/popup.html b/popup.html new file mode 100644 index 0000000..6075751 --- /dev/null +++ b/popup.html @@ -0,0 +1,15 @@ + + + + + + +
+ + + + +
+ + + \ No newline at end of file diff --git a/popup.js b/popup.js new file mode 100644 index 0000000..34de80b --- /dev/null +++ b/popup.js @@ -0,0 +1,44 @@ +var state = document.getElementById('state'); +var subject = document.getElementById('subject'); +var message = document.getElementById('message'); +var save = document.getElementById('save'); + +function set_local_storage() +{ + chrome.storage.sync.set( + { + 'chz_bbs_subject': subject.value, + 'chz_bbs_message' : message.value + }, + function() + { + save.innerHTML = "sauvegardé ^.^" + + setTimeout( + function() + { + save.innerHTML = "sauvegarder" + }, + 1000 + ); + } + ); +} + +function get_local_storage() +{ + chrome.storage.sync.get( + [ + 'chz_bbs_subject', + 'chz_bbs_message' + ], + function(result) + { + if(result.chz_bbs_subject != undefined) subject.value = result.chz_bbs_subject; + if(result.chz_bbs_message != undefined) message.value = result.chz_bbs_message; + } + ); +} + +get_local_storage(); +save.addEventListener('click', set_local_storage); \ No newline at end of file