Skip to content
This repository has been archived by the owner on Jul 30, 2019. It is now read-only.

Commit

Permalink
Replace is… an interesting function
Browse files Browse the repository at this point in the history
Fixes #38
  • Loading branch information
g3rv4 committed May 29, 2019
1 parent f0a5a08 commit 32d0942
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Gruntfile.js
Expand Up @@ -124,7 +124,8 @@ module.exports = function (grunt) {
// we'd need to grab it from ff... but that may have already been filled
let content = grunt.file.read("dist/modulesjs/content_script.js");

content = content.replace('return "placeholder";', injected);
// escape the dollar sign to avoid replacements: https://es.stackoverflow.com/a/267800/11272
content = content.replace('return "placeholder";', injected.replace(/\$/g, "$$$$"));

grunt.file.write("dist/ff/content_script.js", content);
grunt.file.delete("dist/ff/injected_script.js");
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/baseMessageModifierPlugin.ts
Expand Up @@ -64,10 +64,12 @@ export default abstract class BaseMessageModifierPlugin extends BasePlugin {
text = this.doChange(text);

for (let i = 0; i < code.length; i++) {
text = text.replace(`||refinedCode${i}||`, code[i]);
// escape the dollar sign to avoid replacements: https://es.stackoverflow.com/a/267800/11272
text = text.replace(`||refinedCode${i}||`, code[i].replace(/\$/g, "$$$$"));
}
for (let i = 0; i < blocks.length; i++) {
text = text.replace(`||refinedBlock${i}||`, blocks[i]);
// escape the dollar sign to avoid replacements: https://es.stackoverflow.com/a/267800/11272
text = text.replace(`||refinedBlock${i}||`, blocks[i].replace(/\$/g, "$$$$"));
}

e.set(key, text);
Expand Down

0 comments on commit 32d0942

Please sign in to comment.