添加混淆和刪掉不用的代碼

This commit is contained in:
Jesse-Ma
2022-11-29 09:46:13 +08:00
parent 79c1831e6f
commit af869c2423
13 changed files with 1842 additions and 718 deletions

View File

@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es5",
"target": "esnext",
"module": "esnext",
"baseUrl": "./",
"jsx": "preserve",
@@ -15,6 +15,10 @@
"dom",
"dom.iterable",
"scripthost"
]
],
"removeComments": true,
},
"vueCompilerOptions": {
"target": 2.7
}
}

1432
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -11,19 +11,16 @@
},
"dependencies": {
"axios": "^0.26.0",
"canvas-toBlob": "^1.0.0",
"clipboard": "^2.0.11",
"core-js": "^3.8.3",
"crypto-js": "^4.1.1",
"escape-html": "^1.0.3",
"file-saver": "^2.0.5",
"nprogress": "^0.2.0",
"pako": "^2.0.4",
"qrcode": "^1.5.0",
"view-design": "^4.0.0",
"vue": "^2.6.14",
"vue": "^2.7.7",
"vue-axios": "^3.4.1",
"vue-contextmenu": "^1.5.11",
"vue-i18n": "^8.27.2",
"vue-router": "^3.5.1"
},
@@ -37,8 +34,12 @@
"compression-webpack-plugin": "^10.0.0",
"eslint": "^7.32.0",
"eslint-plugin-vue": "^8.0.3",
"javascript-obfuscator": "^4.0.0",
"vue-cli-plugin-iview": "^2.0.0",
"vue-template-compiler": "^2.6.14"
"vue-template-compiler": "^2.6.14",
"webpack-bundle-analyzer": "^4.7.0",
"webpack-cli": "^5.0.0",
"webpack-obfuscator": "^3.5.1"
},
"eslintConfig": {
"root": true,

View File

@@ -5,13 +5,6 @@ import axios from 'axios'
import VueAxios from 'vue-axios'
import './plugins/iview.js'
import i18n from './i18n/'
import VueContextMenu from 'vue-contextmenu'
Vue.use(VueContextMenu)
axios.defaults.baseURL="https://flagnote.com";

View File

@@ -1,201 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2018 Matheus Avellar
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -1,25 +0,0 @@
# Textarea with Line Numbers
<p align="center"> <i>I'm definitely not very good at naming projects</i> </p>
---
This is a simple script to add dynamic line numbers to a textarea. By adding
`tln.js` and `tln.css` (or their corresponding minified versions) to an HTML
file and then calling the `TLN.append_line_numbers( id )` function, the
`<textarea>` with the specified ID will be *numberified™*.
When and if you get sick of those pesky numbers on the side of your textarea,
you can call `TLN.remove_line_numbers( id )` and they'll poof out of existence,
as if they were never there.
You can check the [demo](https://matheusavellar.github.io/textarea-line-numbers/demo.html),
or this sample screenshot of what it looks like (with some additional CSS
styling):
<p align="center">
<img alt="Screenshot of sample code in which each line is numbered accordingly" src="http://i.imgur.com/imEKehF.png"/>
</p>
**Note:** Example code and file header ("`file.bc`") seen in screenshot are sold
separately and may or may not be available at your local convenience store.

View File

@@ -1,36 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title> Textarea with line numbers </title>
<style type="text/css">
/* none of this truly matters, except maybe the wrapper size */
body{text-align:center}
h1,button{margin:25px;}
label,input{margin:0;vertical-align:middle;}
#wrapper{border:1px solid red;position:relative;
height:500px;width:500px;margin:15px auto}
#wrapper::before {
content:"wrapper";text-transform: uppercase;left:0px;
position:absolute;top:-18px;font-size:16px;color:red; }
</style>
<link rel="stylesheet" type="text/css" href="./tln.min.css"/>
<script type="text/javascript" src="./tln.min.js"></script>
</head>
<body>
<h1> Example </h1>
<button onclick="TLN.append_line_numbers('test')"> NUMBERIFY! </button>
<button onclick="TLN.remove_line_numbers('test')"> UN-NUMBERIFY! </button>
<div id="wrapper">
<textarea id="test" class="banana-cake"></textarea>
</div>
<label>
Width:
<input oninput="wrapper.style.width=this.value+'px';" type="range" value="500" min="100" max="700" />
</label>
<label>
Height:
<input oninput="wrapper.style.height=this.value+'px';" type="range" value="500" min="100" max="700" />
</label>
</body>
</html>

View File

@@ -1,48 +0,0 @@
.tln-active, .tln-wrapper, .tln-line {
margin: 0;
border: 0;
padding: 0;
outline: 0;
box-sizing: border-box;
vertical-align: middle;
list-style: none;
}
.tln-active {
display: inline-block;
padding: 0.625em;
width: calc(100% - 3em);
height: 100%;
font-size: 1em;
line-height: 1.5;
font-family: "Roboto Mono", monospace;
word-break: break-all;
border: 1px solid #aeaeae;
background-color: #fff;
resize: none;
overflow-wrap: normal;
overflow-x: auto;
white-space: pre;
}
.tln-wrapper {
width: 3em;
padding: 0.6875em 0.3125em 2.1875em;
height: 100%;
word-break: break-all;
overflow: hidden;
display: inline-block;
counter-reset: line;
}
.tln-line {
width: 100%;
display: block;
text-align: right;
line-height: 1.5;
font-size: 1em;
color: #aeaeae;
}
.tln-line::before {
counter-increment: line;
content: counter(line);
font-size: 1em;
user-select: none;
}

View File

@@ -1,138 +0,0 @@
const TLN = {
eventList: {},
update_line_numbers: function(ta, el) {
// Let's check if there are more or less lines than before
const line_count = ta.value.split("\n").length;
const child_count = el.children.length;
let difference = line_count - child_count;
// If there is any positive difference, we need to add more line numbers
if(difference > 0) {
// Create a fragment to work with so we only have to update DOM once
const frag = document.createDocumentFragment();
// For each new line we need to add,
while(difference > 0) {
// Create a <span>, add TLN class name, append to fragment and
// update difference
const line_number = document.createElement("span");
line_number.className = "tln-line";
frag.appendChild(line_number);
difference--;
}
// Append fragment (with <span> children) to our wrapper element
el.appendChild(frag);
}
// If, however, there's negative difference, we need to remove line numbers
while(difference < 0) {
// Simple stuff, remove last child and update difference
el.removeChild(el.lastChild);
difference++;
}
},
append_line_numbers: function(id) {
// Get reference to desired <textarea>
const ta = document.getElementById(id);
// If getting reference to element fails, warn and leave
if(ta == null) {
return console.warn("[tln.js] Couldn't find textarea of id '"+id+"'");
}
// If <textarea> already has TLN active, warn and leave
if(ta.className.indexOf("tln-active") != -1) {
return console.warn("[tln.js] textarea of id '"+id+"' is already numbered");
}
// Otherwise, we're safe to add the class name and clear inline styles
ta.classList.add("tln-active");
ta.style = {};
// Create line numbers wrapper, insert it before <textarea>
const el = document.createElement("div");
el.className = "tln-wrapper";
ta.parentNode.insertBefore(el, ta);
// Call update to actually insert line numbers to the wrapper
TLN.update_line_numbers(ta, el);
// Initialize event listeners list for this element ID, so we can remove
// them later if needed
TLN.eventList[id] = [];
// Constant list of input event names so we can iterate
const __change_evts = [
"propertychange", "input", "keydown", "keyup"
];
// Default handler for input events
const __change_hdlr = function(ta, el) {
return function(e) {
// If pressed key is Left Arrow (when cursor is on the first character),
// or if it's Enter/Home, then we set horizontal scroll to 0
// Check for .keyCode, .which, .code and .key, because the web is a mess
// [Ref] stackoverflow.com/a/4471635/4824627
if((+ta.scrollLeft==10 && (e.keyCode==37||e.which==37
||e.code=="ArrowLeft"||e.key=="ArrowLeft"))
|| e.keyCode==36||e.which==36||e.code=="Home"||e.key=="Home"
|| e.keyCode==13||e.which==13||e.code=="Enter"||e.key=="Enter"
|| e.code=="NumpadEnter")
ta.scrollLeft = 0;
// Whether we scrolled or not, let's check for any line count updates
TLN.update_line_numbers(ta, el);
}
}(ta, el);
// Finally, iterate through those event names, and add listeners to
// <textarea> and to events list
/// TODO: Performance gurus: is this suboptimal? Should we only add a few
/// listeners? I feel the update method is optimal enough for this to not
/// impact too much things.
for(let i = __change_evts.length - 1; i >= 0; i--) {
ta.addEventListener(__change_evts[i], __change_hdlr);
TLN.eventList[id].push({
evt: __change_evts[i],
hdlr: __change_hdlr
});
}
// Constant list of scroll event names so we can iterate
const __scroll_evts = [ "change", "mousewheel", "scroll" ];
// Default handler for scroll events (pretty self explanatory)
const __scroll_hdlr = function(ta, el) {
return function() { el.scrollTop = ta.scrollTop; }
}(ta, el);
// Just like before, iterate and add listeners to <textarea> and to list
/// TODO: Also just like before: performance?
for(let i = __scroll_evts.length - 1; i >= 0; i--) {
ta.addEventListener(__scroll_evts[i], __scroll_hdlr);
TLN.eventList[id].push({
evt: __scroll_evts[i],
hdlr: __scroll_hdlr
});
}
},
remove_line_numbers: function(id) {
// Get reference to <textarea>
const ta = document.getElementById(id);
// If getting reference to element fails, warn and leave
if(ta == null) {
return console.warn("[tln.js] Couldn't find textarea of id '"+id+"'");
}
// If <textarea> already doesn't have TLN active, warn and leave
if(ta.className.indexOf("tln-active") == -1) {
return console.warn("[tln.js] textarea of id '"+id+"' isn't numbered");
}
// Otherwise, remove class name
ta.classList.remove("tln-active");
// Remove previous sibling if it's our wrapper (otherwise, I guess 'woops'?)
const __wrapper_chck = ta.previousSibling;
if(__wrapper_chck.className == "tln-wrapper")
__wrapper_chck.remove();
// If somehow there's no event listeners list, we can leave
if(!TLN.eventList[id]) return;
// Otherwise iterate through listeners list and remove each one
for(let i = TLN.eventList[id].length - 1; i >= 0; i--) {
const evt = TLN.eventList[id][i];
ta.removeEventListener(evt.evt, evt.hdlr);
}
// Finally, delete the listeners list for that ID
delete TLN.eventList[id];
}
}
export default TLN;

View File

@@ -1 +0,0 @@
.tln-active,.tln-wrapper,.tln-line{margin:0;border:0;padding:0;outline:0;box-sizing:border-box;vertical-align:middle;list-style:none}.tln-active{display:inline-block;padding:.625em;width:calc(100% - 3em);height:100%;word-break:break-all;border:1px solid #aeaeae;background-color:#fff;resize:none;overflow-wrap:normal;overflow-x:auto;white-space:pre;font:1em/1.5 "Roboto Mono",monospace}.tln-wrapper{width:3em;padding:.6875em .3125em 2.1875em;height:100%;word-break:break-all;overflow:hidden;display:inline-block;counter-reset:line}.tln-line{width:100%;display:block;text-align:right;line-height:1.5;font-size:1em;color:#aeaeae}.tln-line::before{counter-increment:line;content:counter(line);font-size:1em;user-select:none}

View File

@@ -1 +0,0 @@
const TLN={eventList:{},update_line_numbers:function(e,t){let n=e.value.split("\n").length-t.children.length;if(n>0){const e=document.createDocumentFragment();for(;n>0;){const t=document.createElement("span");t.className="tln-line",e.appendChild(t),n--}t.appendChild(e)}for(;n<0;)t.removeChild(t.lastChild),n++},append_line_numbers:function(e){const t=document.getElementById(e);if(null==t)return console.warn("[tln.js] Couldn't find textarea of id '"+e+"'");if(-1!=t.className.indexOf("tln-active"))return console.warn("[tln.js] textarea of id '"+e+"' is already numbered");t.classList.add("tln-active"),t.style={};const n=document.createElement("div");n.className="tln-wrapper",t.parentNode.insertBefore(n,t),TLN.update_line_numbers(t,n),TLN.eventList[e]=[];const l=["propertychange","input","keydown","keyup"],o=function(e,t){return function(n){(10!=+e.scrollLeft||37!=n.keyCode&&37!=n.which&&"ArrowLeft"!=n.code&&"ArrowLeft"!=n.key)&&36!=n.keyCode&&36!=n.which&&"Home"!=n.code&&"Home"!=n.key&&13!=n.keyCode&&13!=n.which&&"Enter"!=n.code&&"Enter"!=n.key&&"NumpadEnter"!=n.code||(e.scrollLeft=0),TLN.update_line_numbers(e,t)}}(t,n);for(let n=l.length-1;n>=0;n--)t.addEventListener(l[n],o),TLN.eventList[e].push({evt:l[n],hdlr:o});const r=["change","mousewheel","scroll"],s=function(e,t){return function(){t.scrollTop=e.scrollTop}}(t,n);for(let n=r.length-1;n>=0;n--)t.addEventListener(r[n],s),TLN.eventList[e].push({evt:r[n],hdlr:s})},remove_line_numbers:function(e){const t=document.getElementById(e);if(null==t)return console.warn("[tln.js] Couldn't find textarea of id '"+e+"'");if(-1==t.className.indexOf("tln-active"))return console.warn("[tln.js] textarea of id '"+e+"' isn't numbered");t.classList.remove("tln-active");const n=t.previousSibling;if("tln-wrapper"==n.className&&n.remove(),TLN.eventList[e]){for(let n=TLN.eventList[e].length-1;n>=0;n--){const l=TLN.eventList[e][n];t.removeEventListener(l.evt,l.hdlr)}delete TLN.eventList[e]}}};

View File

@@ -1,12 +1,33 @@
const { defineConfig } = require("@vue/cli-service");
const CompressionPlugin = require("compression-webpack-plugin");
const WebpackObfuscator = require('webpack-obfuscator');
module.exports = defineConfig({
assetsDir: 'static',
productionSourceMap: false,
configureWebpack: {
// devtool: false,
plugins: [
new WebpackObfuscator({
compact: true,//压缩代码
controlFlowFlattening: true,//是否启用控制流扁平化(降低1.5倍的运行速度)
controlFlowFlatteningThreshold: 1,//应用概率;在较大的代码库中,建议降低此值,因为大量的控制流转换可能会增加代码的大小并降低代码的速度。
deadCodeInjection: true,//随机的死代码块(增加了混淆代码的大小)
deadCodeInjectionThreshold: 1,//死代码块的影响概率
debugProtection: true,//此选项几乎不可能使用开发者工具的控制台选项卡
disableConsoleOutput: true,//通过用空函数替换它们来禁用console.logconsole.infoconsole.error和console.warn。这使得调试器的使用更加困难。
identifierNamesGenerator: 'hexadecimal',//标识符的混淆方式 hexadecimal(十六进制) mangled(短标识符)
log: false,
renameGlobals: false,//是否启用全局变量和函数名称的混淆
rotateStringArray: true,//通过固定和随机(在代码混淆时生成)的位置移动数组。这使得将删除的字符串的顺序与其原始位置相匹配变得更加困难。如果原始源代码不小,建议使用此选项,因为辅助函数可以引起注意。
selfDefending: true,//混淆后的代码,不能使用代码美化,同时需要配置 cpmpat:true;
stringArray: true,//删除字符串文字并将它们放在一个特殊的数组中
stringArrayThreshold: 1,
transformObjectKeys: true,
unicodeEscapeSequence: false//允许启用/禁用字符串转换为unicode转义序列。Unicode转义序列大大增加了代码大小并且可以轻松地将字符串恢复为原始视图。建议仅对小型源代码启用此选项。
}, ['static/js/chunk-vendors.*.js']),
new CompressionPlugin({
algorithm: "gzip", // 使用gzip压缩
test: /\.js$|\.html$|\.png$|\.jpg$|\.svg$|\.css$/, // 匹配文件名

627
yarn.lock

File diff suppressed because it is too large Load Diff