@xpadev-net/niconicomments 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/bundle.js +11 -5
  2. package/package.json +1 -1
package/dist/bundle.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- niconicomments.js v0.2.3
2
+ niconicomments.js v0.2.4
3
3
  (c) 2021 xpadev-net https://xpadev.net
4
4
  Released under the MIT License.
5
5
  */
@@ -700,7 +700,7 @@
700
700
  quote = i;
701
701
  }
702
702
  else if (i.match(/["']/) && quote === i && last_i !== "\\") {
703
- result.push(string.replace("\\n", "\n"));
703
+ result.push(replaceAll(string, "\\n", "\n"));
704
704
  quote = "";
705
705
  string = "";
706
706
  }
@@ -766,14 +766,12 @@
766
766
  if ((item.target === "コメ" && comment.owner) || (item.target === "投コメ" && !comment.owner) || (item.target === "含まない" && comment.owner))
767
767
  continue;
768
768
  if ((item.condition === "完全一致" && comment.content === item.keyword) || (item.condition === "部分一致" && comment.content.indexOf(item.keyword) !== -1)) {
769
- console.log(item, comment);
770
769
  if (item.range === "単") {
771
- comment.content = comment.content.replace(new RegExp(item.keyword, "g"), item.replace);
770
+ comment.content = replaceAll(comment.content, item.keyword, item.replace);
772
771
  }
773
772
  else {
774
773
  comment.content = item.replace;
775
774
  }
776
- console.log(comment);
777
775
  if (item.loc) {
778
776
  loc = item.loc;
779
777
  }
@@ -911,6 +909,14 @@
911
909
  return [hex.slice(0, 2), hex.slice(2, 4), hex.slice(4, 6)].map(function (str) {
912
910
  return parseInt(str, 16);
913
911
  });
912
+ };
913
+ var replaceAll = function (string, target, replace) {
914
+ var count = 0;
915
+ while (string.indexOf(target) !== -1 && count < 100) {
916
+ string = string.replace(target, replace);
917
+ count++;
918
+ }
919
+ return string;
914
920
  };
915
921
 
916
922
  return NiconiComments;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xpadev-net/niconicomments",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "NiconiComments is a comment drawing library that is somewhat compatible with the official Nico Nico Douga player.",
5
5
  "main": "dist/bundle.js",
6
6
  "scripts": {