Skip to content

Commit

Permalink
initial code
Browse files Browse the repository at this point in the history
  • Loading branch information
iumehara committed Jun 5, 2016
0 parents commit 1fcabdc
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
9 changes: 9 additions & 0 deletions background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
chrome.runtime.onMessage.addListener(function(message, sender) {
if (message.content == 'ready') {
chrome.pageAction.show(sender.tab.id);
}
});

chrome.pageAction.onClicked.addListener(function(tab) {
chrome.tabs.sendMessage(tab.id, {content: "setTimes"});
});
27 changes: 27 additions & 0 deletions content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
chrome.runtime.sendMessage(
{content: 'ready'}
);

chrome.runtime.onMessage.addListener(function(message, sender) {
if (message.content == "setTimes") {
setTimes();
}
});

var setTimes = function() {
for (var i=0; i<31; i++) {
var day;
i + 1 < 10 ? day = "0" + (i + 1) : day = i + 1;
var idString = "ctl00_ContentMain_AttendanceTableRepeater_ctl" + day;
var startInputId = idString + "_txtStartTime";
var endInputId = idString + "_txtEndTime";
setValueIfBlank(document.getElementById(startInputId), '09:00');
setValueIfBlank(document.getElementById(endInputId), '18:00');
};
};

var setValueIfBlank = function(input, value) {
if (input && input.value == "" && input.style['background-color'] == "lightyellow") {
input.value = value;
};
};
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"manifest_version": 2,
"name": "AttendancerXP",
"version": "0.1",
"icons": {
"128": "icon.png"
},
"background": {
"persistent": false,
"scripts": ["background.js"]
},
"content_scripts": [{
"matches": ["https://attendance.cvi.co.jp/AttendanceTableFullSimp.aspx"],
"js": ["content.js"]
}],
"page_action": {
"default_icon": "icon.png"
}
}

0 comments on commit 1fcabdc

Please sign in to comment.