Skip to content

Commit

Permalink
v0.2.1 日時をコードブロックに(:99:が絵文字になってしまうことがあるため)
Browse files Browse the repository at this point in the history
  • Loading branch information
sakasa committed Aug 21, 2023
1 parent 1bc1894 commit 4e9e087
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
20 changes: 13 additions & 7 deletions attendance-ext/contentScript.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const sleep = waitTime => new Promise( resolve => setTimeout(resolve, waitTime) );

let user = '';
let mfckExtUser = '';
let chatConf = {};

function loadChatConf(){
Expand All @@ -13,6 +13,10 @@ function loadChatConf(){
});
};

function messageFormat(userText, dateText, text) {
return `${userText} - \`${dateText}\` ${text}`
}

function getUserText() {
// console.log('getUserText')
let userElem = document.getElementsByClassName("attendance-header-user-name")[0];
Expand All @@ -36,9 +40,10 @@ function getUserText() {
// console.log(userName);

const re = /^(.+?)さん$/
user = re.exec(userName)[1];
mfckExtUser = re.exec(userName)[1];
mfckExtUser = mfckExtUser.replaceAll(/[  ]/g, ' ');
// console.log(user);
return user;
return mfckExtUser;
}
function getDateText() {
// console.log('getDateText')
Expand All @@ -52,16 +57,17 @@ function getDateText() {
}
function getMessageText(text) {
// console.log(text);
return `${user||getUserText()} - ${getDateText()} ${text}`
return messageFormat(mfckExtUser||getUserText(), getDateText(), text)
}

/**
* for `mypage.moneyforward.com`
*/
function getUserText2() {
const ret = document.getElementById('root').firstChild.firstChild.lastChild.lastChild.firstChild.firstChild.innerText;
mfckExtUser = document.getElementById('root').firstChild.firstChild.lastChild.lastChild.firstChild.firstChild.innerText;
mfckExtUser = mfckExtUser.replaceAll(/[  ]/g, ' ');
// console.log(ret);
return ret;
return mfckExtUser;
}
/**
* for `mypage.moneyforward.com`
Expand All @@ -85,7 +91,7 @@ function getDateText2() {
*/
function getMessageText2(text) {
// console.log(text);
return `${user||getUserText2()} - ${getDateText2()} ${text}`
return messageFormat(mfckExtUser||getUserText2(), getDateText2(), text)
}

function dataJson(messageText){
Expand Down
2 changes: 1 addition & 1 deletion attendance-ext/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "Kintai Post with Moneyforward Attendance",
"version": "0.2.0",
"version": "0.2.1",
"description": "「マネーフォワード クラウド勤怠」の打刻に合わせて、設定したチャットに投稿を行います。チャットの設定は拡張機能のオプションページで行ってください。",
"permissions": [
"declarativeContent",
Expand Down

0 comments on commit 4e9e087

Please sign in to comment.