Skip to content

Commit

Permalink
UglifyJSの最小化のバグとスタイルを修正
Browse files Browse the repository at this point in the history
  • Loading branch information
qq542vev committed Mar 21, 2023
1 parent a71520c commit f5fd14b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
12 changes: 9 additions & 3 deletions source/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* @file 「Bookmarklet Generator」用のスクリプト
* @author {@link https://purl.org/meta/me/|qq542vev}
* @version 2023-03-17
* @version 2023-03-21
* @since 2023-03-13
* @copyright Copyright (C) 2023-2023 qq542vev. Some rights reserved.
* @license {@link https://creativecommons.org/licenses/by/4.0/|CC-BY}
Expand Down Expand Up @@ -281,10 +281,16 @@ function pageRewrite() {
outputBookmarklet($.trim(jsCode));
} else if(optimize === "uglifyjs") {
try {
outputBookmarklet(UglifyJS.minify(jsCode, {
var minifed = UglifyJS.minify(jsCode, {
"warnings": true,
"fromString": true
}).code);
}).code;

if(/^!function\(\)\{.*\}\(\);/.test(minifed)) {
minifed = "(function(){" + minifed.substring(12, minifed.length - 4) + "})();";
}

outputBookmarklet(minifed);
} catch(error) {
outputMessage(
error.name,
Expand Down
4 changes: 2 additions & 2 deletions source/minified/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion source/minified/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion source/minified/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f5fd14b

Please sign in to comment.