Here's the snippet:
//Get userId,questionId and title
let btn0 = document.createElement('input');
btn0.type = "button";
btn0.value = 'Read Content';
btn0.onclick = () => {
console.clear();
let b = [["Item","String"]];
let c = document.querySelectorAll('div#un1')[0].children;
let a = Array.from(c);
a.forEach((e , i) => {
b.push([i + 1,e.innerText]);
});
localStorage.setItem("test",JSON.stringify(b));
console.log(JSON.stringify(b));
}
if(m0)m0.prepend(btn0);
I was just trying to replace btn0 to btn1 and m0 to m1 to start another snippet without rewriting all of common stuff. I ended up using something I wrote but would like to be able to use the builtin tool in Chrome dev tools.
I was hoping one of you knows how to use the replacement tool on Chrome Dev Tools better than I.
It seems the regex engine used in Chrome snippets is still JavaScript RegExp
, but replacing functionality is not the regular one.
There are two approaches here:
(?<=m|n)0
=> 1
(?<name>m|n)0
=> $<name>1
Do not forget to click the .*
icon to enable regular expression replace mode!