I use regex to parse javascript code (using an ES parser such as Esprima is not an option to limit the technical environment).
Subject code (processed code):
(function() {
$('#3bf779cd').replaceWith("<div class=\'shows\'>\n<\/div>");
window.fadeItems();
}).call(this);
The value that interests me is the first parameter replaceWith, which is a string literal. I get this variable with a regex:
const subjectValue = subjectCode.match(/\.replaceWith\(((["'])(?:(?=(\\?))\3.)*?\2)/m)[1].slice(1, -1);
console.log(subjectValue);
The result of this:
<div class=\'shows\'>\n<\/div>
How to avoid subjectValuein such a way that the result is:
<div class='shows'>
</div>
Just using unescapeit has no effect.
If I am not mistaken, the question arises of how to cancel this value:
console.log('"<div class=\\\'shows\\\'>\\\\n<\\\/div>"');
Gajus source
share