Last active
March 18, 2025 15:43
-
-
Save claudianus/780f9a50c50dc2a921fa7b915f0d77e1 to your computer and use it in GitHub Desktop.
build obfuscated tampermonkey user script and publish to put.re from ES6+ with gulp automator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const gulp = require("gulp") | |
const babel = require("gulp-babel") | |
const javascriptObfuscator = require('gulp-javascript-obfuscator') | |
const rename = require('gulp-rename') | |
const header = require('gulp-header') | |
const footer = require('gulp-footer') | |
const upload = require('gulp-upload') | |
const package = require('./package.json') | |
gulp.task("default", function () { | |
return gulp.src("src/index.js") | |
.pipe(babel()) | |
.pipe(javascriptObfuscator({ | |
compact: true, | |
controlFlowFlattening: false, | |
controlFlowFlatteningThreshold: 0.75, | |
deadCodeInjection: false, | |
deadCodeInjectionThreshold: 0.4, | |
debugProtection: false, | |
debugProtectionInterval: false, | |
disableConsoleOutput: true, | |
domainLock: [], | |
identifierNamesGenerator: 'hexadecimal', | |
identifiersPrefix: '', | |
inputFileName: '', | |
log: false, | |
renameGlobals: false, | |
reservedNames: [], | |
reservedStrings: [], | |
rotateStringArray: true, | |
seed: 0, | |
selfDefending: true, | |
sourceMap: false, | |
sourceMapBaseUrl: '', | |
sourceMapFileName: '', | |
sourceMapMode: 'separate', | |
stringArray: true, | |
stringArrayEncoding: 'rc4', | |
stringArrayThreshold: 1, | |
target: 'browser', | |
transformObjectKeys: true, | |
unicodeEscapeSequence: true | |
})) | |
.pipe(rename(path => { | |
path.basename = `${package.name}-${package.version}` | |
path.extname = '.user.js' | |
})) | |
.pipe(header(`// ==UserScript== | |
// @name ${package.nameKo} | |
// @namespace ${package.homepage} | |
// @version ${package.version} | |
// @description ${package.description} | |
// @author ${package.author} | |
// @include https://m.search.naver.com/* | |
// @run-at document-idle | |
// @noframes | |
// @grant none | |
// @updateURL none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
`)) | |
.pipe(footer(` | |
})();`)) | |
.pipe(gulp.dest("dist")) | |
.pipe(upload({ | |
server: 'https://api.put.re/upload', | |
callback(err, data, res) { | |
if(err) { | |
console.error(err) | |
return | |
} | |
console.log(data.toString()) | |
} | |
})) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment