Image for post
Image for post

Preview release of shift-refactor

Transform, manipulate, and deobfuscate JavaScript with shift-refactor

$ npm install shift-refactor

What does shift-refactor do?

refactor.rename(`IdentifierExpression[name=”oldName”]`, "newName")

Who is shift-refactor for?

How can I use it?

$ npm install shift-refactor shift-parser
const { RefactorSession } = require('shift-refactor');
const { parseScript } = require('shift-parser');
const fs = require('fs');const fileContents = fs.readFileSync('./source.js', 'utf8');const tree = parseScript(fileContents);const refactor = new RefactorSession(tree);refactor.rename('IdentifierExpression[name="oldName"]', 'newName');refactor.insertBefore(
node => `console.log("Calling ${}()")`
console.log("Calling newName()");
console.log("Calling otherFunction()");

I write about JavaScript, Reverse Engineering, Security, and Credential Stuffing. Also a speaker, O'Reilly Author, creator of Plato, Director at Shape Security.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store