diff --git a/src/www/assets/index.css b/src/www/assets/index.css
index b472863..8b1ab5c 100644
--- a/src/www/assets/index.css
+++ b/src/www/assets/index.css
@@ -97,4 +97,9 @@ input[type=range]::-webkit-slider-thumb {
.warning {
color: #f00;
+}
+
+.not-working {
+ color: #808080;
+ text-decoration: line-through;
}
\ No newline at end of file
diff --git a/src/www/index.html b/src/www/index.html
index b66c182..a023923 100644
--- a/src/www/index.html
+++ b/src/www/index.html
@@ -16,8 +16,7 @@
Please Wait...
- Plexstorm Capture V1.0.0-alpha.1
by a161803398
- Donation popup is not working in this version.
+ Plexstorm Capture V1.0.1-alpha.2
by a161803398
@@ -34,7 +33,7 @@ ms video playing time
-
+
@@ -58,8 +57,8 @@
-
-
+
+
@@ -74,8 +73,8 @@ Chat records save in chat_logs folder
Chat Room:http://localhost:1069
Donation:http://localhost:1069/donate
- Subscription:http://localhost:1069/subscript
- Top Donate:http://localhost:1069/topDonate
+ Subscription:http://localhost:1069/subscript
+ Top Donate:http://localhost:1069/topDonate
Support development: www.patreon.com/a1618
diff --git a/src/www/js/decodeMsg.js b/src/www/js/decodeMsg.js
index c044e0b..adc3d76 100644
--- a/src/www/js/decodeMsg.js
+++ b/src/www/js/decodeMsg.js
@@ -5,15 +5,7 @@ function createElementFromHTML(htmlString) {
}
function getPDCount(str){
- let pd = 0;
- for(let i = 0; i < str.length; i++){
- const curCharCode = str.charCodeAt(i);
- if(curCharCode >= 48 && curCharCode <= 57){ //0 to 9
- pd *= 10;
- pd += curCharCode - 48;
- }
- }
- return pd;
+ return parseInt(str.match(/has tipped (\d+)/)[1]);
}
const userMap = new Map();
@@ -75,75 +67,76 @@ function decodeMsg(tar){
msgText: ''
};
-
- const userSpan = decodeElement.children[0];
- if (userSpan) {
- msgObj.userName = userSpan.innerText.trim();
- if(msgObj.userName == "asixteen"){
- msgObj.userName = "a161803398";
+ if (decodeElement.classList.contains('highlight-message')) {
+ msgObj.msgType = 3;
+
+ const msgP = decodeElement.children[0];
+
+ const userSpan = msgP.children[0];
+ if (userSpan) {
+ msgObj.userName = userSpan.innerText.trim();
+ }
+
+ if (msgP) {
+ msgObj.msgText = msgP.innerText.trim();
+ }
+ } else {
+ const userSpanWrapper = decodeElement.children[0];
+ const userSpan = userSpanWrapper.children[0]
+
+ if (userSpan) {
+ msgObj.userName = userSpan.innerText.trim();
+ }else{
+ msgObj.userName = userSpanWrapper.innerText.trim();
+ }
+
+ const msgP = decodeElement.children[1];
+
+ if (msgP) {
+ msgObj.msgText = msgP.innerText.trim();
}
+ }
- // FIXME: don't work anymore
- // const classList = userSpan.classList;
- // if(classList.contains('color-female')){
- // msgObj.userSex = 1;
- // }else if(classList.contains('color-trans')){
- // msgObj.userSex = 2;
- // }
+ let userObj = null;
+ if(userMap.has(msgObj.userName)){ //old user
+ userObj = userMap.get(msgObj.userName); //retrieve userObj
+ }else{
+ userObj = {preMsg: null, ucid: userMap.size};
+ userMap.set(msgObj.userName, userObj); //put userObj to map and increase map size
}
+ msgObj.ucid = userObj.ucid; //set ucid
- const msgP = decodeElement.children[1];
-
- if (msgP) {
- msgObj.msgText = msgP.innerText.trim();
-
- let userObj = null;
- if(userMap.has(msgObj.userName)){ //old user
- userObj = userMap.get(msgObj.userName); //retrieve userObj
- }else{
- userObj = {preMsg: null, ucid: userMap.size};
- userMap.set(msgObj.userName, userObj); //put userObj to map and increase map size
+ if(msgObj.msgType == 3 || msgObj.msgType == 4){
+ if(msgObj.msgType == 3){
+ msgObj['pdAmount'] = getPDCount(msgObj.msgText);
+ }else {
+ msgObj.msgText = curLang.msg['subscript'];
}
- msgObj.ucid = userObj.ucid; //set ucid
- if(msgObj.msgType == 3 || msgObj.msgType == 4){
- if(msgObj.msgType == 3){
- msgObj['pdAmount'] = getPDCount(msgObj.msgText);
- msgObj.msgText = curLang.msg['donate'] + msgObj['pdAmount'] + 'PD';
- }else {
- msgObj.msgText = curLang.msg['subscript'];
- }
+ msgObj['rndNum'] = Math.floor(999999999 * Math.random());
+
+ if(userObj.preMsg != null){
+ msgObj['preMsg'] = userObj.preMsg;
- msgObj['rndNum'] = Math.floor(999999999 * Math.random());
-
- //if(typeof preUserMsgMap[msgObj.userName] != "undefined"){
-
- if(userObj.preMsg != null){
- //msgObj['preMsg'] = preUserMsgMap[msgObj.userName];
- msgObj['preMsg'] = userObj.preMsg;
-
- if(msgObj.msgType == 3){ //for donate only
- const preMsgObj = decodeDonateMsg(msgObj['preMsg']);
- msgObj['preMsg'] = preMsgObj.userMsg;
- if(preMsgObj.vid != null){
- msgObj['vid'] = preMsgObj.vid;
- msgObj['startTime'] = preMsgObj.startTime;
- msgObj['playTime'] = setting.playTimeUnit * msgObj['pdAmount'];
- msgObj['videoType'] = preMsgObj.videoType;
- }
- }
-
- if(!setting.readMsg){
- msgObj['preMsg'] = "";
+ if(msgObj.msgType == 3){ //for donate only
+ const preMsgObj = decodeDonateMsg(msgObj['preMsg']);
+ msgObj['preMsg'] = preMsgObj.userMsg;
+ if(preMsgObj.vid != null){
+ msgObj['vid'] = preMsgObj.vid;
+ msgObj['startTime'] = preMsgObj.startTime;
+ msgObj['playTime'] = setting.playTimeUnit * msgObj['pdAmount'];
+ msgObj['videoType'] = preMsgObj.videoType;
}
- }else{
- msgObj['preMsg'] = "";
}
-
+
+ if(!setting.readMsg){
+ msgObj['preMsg'] = "";
+ }
}else{
- //preUserMsgMap[msgObj.userName] = msgObj.msgText; //record pre-message
- userObj.preMsg = msgObj.msgText; //record pre-message
+ msgObj['preMsg'] = "";
}
- }
+ }else{
+ userObj.preMsg = msgObj.msgText; //record pre-message
+ }
return msgObj;
}
diff --git a/src/www/js/index.js b/src/www/js/index.js
index 2ec37e9..6020d33 100644
--- a/src/www/js/index.js
+++ b/src/www/js/index.js
@@ -46,7 +46,7 @@ donateLink.addEventListener("click", ()=>{
function updateSetting(){
setting.readMsg = readMsgChk.checked;
setting.playYT = playYTChk.checked;
- setting.playPH = playPHChk.checked;
+ setting.playPH = false; // FIXME
setting.defaultShowVideo = defaultShowVideoChk.checked;
setting.logToFile = logToFileChk.checked;
@@ -86,7 +86,7 @@ function updateState(){
loadSetting();
readMsgChk.checked = setting.readMsg;
playYTChk.checked = setting.playYT;
- playPHChk.checked = setting.playPH;
+ playPHChk.checked = false; // FIXME
defaultShowVideoChk.checked = setting.defaultShowVideo;
logToFileChk.checked = setting.logToFile;
@@ -267,24 +267,50 @@ function printMsg(jsonMsg){
}
}
-musicDonateTestBtn.addEventListener('click', (e)=>{
- printMsg(decodeMsg(' a161803398·
' + curLang.msg['testYouTubeDonateMsg'] + '
'));
- printMsg(decodeMsg(' a161803398
has tipped17 PD
'));
- if(curTopDonateMsg == ""){
- //put some dummy message
- updateTopDonate('a161803398: Test Donate');
+musicDonateTestBtn.addEventListener('click', (e)=>{
+ const msgObj = {
+ type: 'chat',
+ msgType: 3, //type-tip
+ userName: 'a161803398',
+ userSex: 0,//male
+ msgText: curLang.msg['donate'] + '17PD',
+ pdAmount: 17,
+ rndNum: parseInt(donateSelect.value),
+ ucid: 0
+ };
+
+ const preMsgObj = decodeDonateMsg(setting.readMsg ? curLang.msg['testYouTubeDonateMsg'] : "");
+ msgObj['preMsg'] = preMsgObj.userMsg;
+ if(preMsgObj.vid != null){
+ msgObj['vid'] = preMsgObj.vid;
+ msgObj['startTime'] = preMsgObj.startTime;
+ msgObj['playTime'] = setting.playTimeUnit * msgObj['pdAmount'];
+ msgObj['videoType'] = preMsgObj.videoType;
}
-
+ printMsg(msgObj);
});
-phFastDonateTestBtn.addEventListener('click', (e)=>{
- printMsg(decodeMsg(' a161803398·
' + curLang.msg['testPornHubDonateMsg'] + '
'));
- printMsg(decodeMsg(' a161803398
has tipped10 PD
'));
- if(curTopDonateMsg == ""){
- //put some dummy message
- updateTopDonate('a161803398: Test Donate');
+phFastDonateTestBtn.addEventListener('click', (e)=>{
+ const msgObj = {
+ type: 'chat',
+ msgType: 3, //type-tip
+ userName: 'a161803398',
+ userSex: 0,//male
+ msgText: curLang.msg['donate'] + '17PD',
+ pdAmount: 17,
+ rndNum: parseInt(donateSelect.value),
+ ucid: 0
+ };
+
+ const preMsgObj = decodeDonateMsg(setting.readMsg ? curLang.msg['testPornHubDonateMsg'] : "");
+ msgObj['preMsg'] = preMsgObj.userMsg;
+ if(preMsgObj.vid != null){
+ msgObj['vid'] = preMsgObj.vid;
+ msgObj['startTime'] = preMsgObj.startTime;
+ msgObj['playTime'] = setting.playTimeUnit * msgObj['pdAmount'];
+ msgObj['videoType'] = preMsgObj.videoType;
}
-
+ printMsg(msgObj);
});