Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
depth1 committed Mar 31, 2018
0 parents commit c4b7ff9
Show file tree
Hide file tree
Showing 12 changed files with 188 additions and 0 deletions.
Binary file added 128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 128_50.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions background.js
Original file line number Diff line number Diff line change
@@ -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({});
}
}
);
15 changes: 15 additions & 0 deletions inject.js
Original file line number Diff line number Diff line change
@@ -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;
}
);
28 changes: 28 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -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"]
}
]
}
57 changes: 57 additions & 0 deletions popup.css
Original file line number Diff line number Diff line change
@@ -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);
}
15 changes: 15 additions & 0 deletions popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<html>
<head>
<meta charset="utf-8">
<link href="popup.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="form">
<input type="text" id="subject" class="input" placeholder="sujet"/>
<textarea id="message" class="input bg-128-50" placeholder="message" rows = 10></textarea>

<button id="save" class="input btn">sauvegarder</button>
</div>
<script src="popup.js"></script>
</body>
</html>
44 changes: 44 additions & 0 deletions popup.js
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit c4b7ff9

Please sign in to comment.