diff --git a/package.json b/package.json index 2fd89a1..c5444a8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "typetalk-emoreact", - "version": "0.1.4", + "version": "0.1.5", "description": "", "scripts": { "build": "rollup --config", diff --git a/src/index.js b/src/index.js index cd6e90e..37c51ec 100644 --- a/src/index.js +++ b/src/index.js @@ -89,6 +89,14 @@ const mountEmoreact = messages => { const typetalk = new Typetalk(); const actions_ = typetalkSideEffect(typetalk)(actions); + let myNameOpt = document.querySelector('.profile-content__name'); + myNameOpt = myNameOpt && myNameOpt.textContent.match(/(.*) さん/); + myNameOpt = myNameOpt && myNameOpt[1]; + + if (!myNameOpt) return; + + const myName = myNameOpt; + messages.forEach(message => { const found = document.querySelector(`a[ng-href="${message.postUrl}"]`); @@ -106,7 +114,7 @@ const mountEmoreact = messages => { root, view.reactions, actions_, - createState(message, new User('Motohiro Ohno 👨🏻‍💻🦀')) + createState(message, new User(myName)) ); }); };