Skip to content

Instantly share code, notes, and snippets.

@lopo12123
Created March 22, 2022 02:42
Show Gist options
  • Save lopo12123/8665856c223737ba3ff2e905cea0565a to your computer and use it in GitHub Desktop.
Save lopo12123/8665856c223737ba3ff2e905cea0565a to your computer and use it in GitHub Desktop.
Remove the watermark that comes with gojs
// npm install 之后先使用
// serve-with-gojs/build-with-gojs
// 对 node_module 中相关的文件进行处理
// 去除开源版本的 gojs 自带的水印
const fs = require('fs')
const path = require('path')
const file_js = path.join(__dirname, './node_modules/gojs/release/go.js')
const file_mjs = path.join(__dirname, './node_modules/gojs/release/go.mjs')
const file_module = path.join(__dirname, './node_modules/gojs/release/go-module.js')
const doReplace = (filePath) => {
fs.readFile(filePath, 'utf8', function (err, data) {
if (err) throw err;
console.log(`[solving] ${filePath}.`)
let hasMatch = false;
// old version
let content = data.replace(/[\w\W]{8}7eba17a4ca3b1a8346[\w\W]{31}/gi, function (match) {
if(match) hasMatch = true;
return 'function(){return true;}'
});
// new version
if(!hasMatch){
content = data.replace(/[^)^{}]*7ca11abfd7330390[^;]*/gi, function (match) {//查找绘制文本的语句
let arr=/]\(([^,]+)/.exec(match); // search all target
return arr && arr.length>=1 && arr[1];
});
}
fs.writeFile(filePath, content, 'utf8', (err) => {
if (err) {
console.log(`[error] in ${filePath}: ${err.toString()}.`)
}
else {
console.log(`[success] ${filePath} replaced.`)
}
});
});
}
(() => {
doReplace(file_js)
doReplace(file_mjs)
doReplace(file_module)
})()
@sortheme
Copy link

sortheme commented Jul 2, 2024

Captura de pantalla 2024-07-02 a la(s) 12 48 28 p  m

this script dosent work on v3. but for go-debug.js file you can use my suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment