Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用webpack打包的方法进行整体重构 #68

Draft
wants to merge 46 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
4951ef4
add: webpack-tampermonkey template
swsoyee Sep 30, 2020
c2b9125
add: .gitignore
swsoyee Oct 1, 2020
45d8c00
fix: webpack import error
swsoyee Oct 1, 2020
6bea570
update: header.js
swsoyee Oct 1, 2020
25b276a
Merge branch 'master' into use-webpack
swsoyee Oct 3, 2020
2d1c633
refactor: PageBottom function
swsoyee Oct 3, 2020
28bbe84
chore: rename pageBottom function name
swsoyee Oct 3, 2020
a3ea552
add: beautifyQaIndex function
swsoyee Oct 3, 2020
fb5164a
add: showMarkMessage function
swsoyee Oct 3, 2020
c98a014
add: OpBadge function
swsoyee Oct 3, 2020
1f515ab
rename: directory
swsoyee Oct 3, 2020
cf3b514
add: hotTag function
swsoyee Oct 3, 2020
4aa034d
add: inputCounter function
swsoyee Oct 3, 2020
1f34eac
rename: opBadge
swsoyee Oct 3, 2020
960fd6a
add: inputPreview function
swsoyee Oct 3, 2020
848eeeb
add: sortTipsByLikes function
swsoyee Oct 3, 2020
524ed71
add: switch button style
swsoyee Oct 3, 2020
b9afa44
add: showTrophyNotEarned function
swsoyee Oct 3, 2020
22a2bfd
add: trophyPieChart function
swsoyee Oct 3, 2020
afd2749
add: trophyEarnedLineChart function
swsoyee Oct 3, 2020
8c33bd4
add: hoverProfile function
swsoyee Oct 3, 2020
0727e64
add: earnedStatusInGuide function
swsoyee Oct 3, 2020
adc3a75
add: gameCompletion function
swsoyee Oct 3, 2020
a6331e9
add: autoCheckIn function
swsoyee Oct 3, 2020
8b8a88f
add: replyContent function
swsoyee Oct 3, 2020
1af4efe
add: allGame function
swsoyee Oct 3, 2020
1f7baea
add: autoPaging function
swsoyee Oct 3, 2020
8529a46
add: highchart global setting
swsoyee Oct 3, 2020
64d2cb3
add: floorIndex function
swsoyee Oct 3, 2020
f482a7c
add: p9TimeTextParser
swsoyee Oct 3, 2020
fa64190
add: priceLinePlot function
swsoyee Oct 3, 2020
a26ee4b
fix: docs
swsoyee Oct 3, 2020
e323965
add: hoverShowReply function
swsoyee Oct 3, 2020
d67ed46
add: discountTitleColor function
swsoyee Oct 3, 2020
a429061
add: bestOnly function
swsoyee Oct 3, 2020
985a356
add: currencyConversion function
swsoyee Oct 3, 2020
461d516
add: earnedTrophiesSummary function
swsoyee Oct 3, 2020
1f560a6
chore: revert readme
swsoyee Oct 3, 2020
027b3bf
fix: change opBadge selector
swsoyee Oct 3, 2020
e3d2163
chore: disable auto check in
swsoyee Oct 4, 2020
a2a0210
add: RevertSubReply function
swsoyee Oct 4, 2020
ccc17f8
add: trophySortByTimestamp function
swsoyee Oct 4, 2020
bd21151
fix: qaBadge function
swsoyee Oct 4, 2020
0200d05
update: sortTipsByLikes style
swsoyee Oct 4, 2020
40726ca
refactor: move criticAverage
swsoyee Oct 4, 2020
5b6c8e8
refactor: criticAverage
Nathaniel-Wu Oct 4, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
95 changes: 95 additions & 0 deletions dist/good-monkey.user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// ==UserScript==
// @name Good Monkey
// @version 0.0.1
// @description This is a good monkey
// @author SettingDust
//
// @include http*://tampermonkey.net/*
//
// @require https://cdn.bootcss.com/jquery/3.3.1/jquery.js
//
// @grant GM_addStyle
// ==/UserScript==

!function(modules) {
var installedModules = {};
function __webpack_require__(moduleId) {
if (installedModules[moduleId]) return installedModules[moduleId].exports;
var module = installedModules[moduleId] = {
i: moduleId,
l: !1,
exports: {}
};
return modules[moduleId].call(module.exports, module, module.exports, __webpack_require__),
module.l = !0, module.exports;
}
__webpack_require__.m = modules, __webpack_require__.c = installedModules, __webpack_require__.d = function(exports, name, getter) {
__webpack_require__.o(exports, name) || Object.defineProperty(exports, name, {
enumerable: !0,
get: getter
});
}, __webpack_require__.r = function(exports) {
"undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(exports, Symbol.toStringTag, {
value: "Module"
}), Object.defineProperty(exports, "__esModule", {
value: !0
});
}, __webpack_require__.t = function(value, mode) {
if (1 & mode && (value = __webpack_require__(value)), 8 & mode) return value;
if (4 & mode && "object" == typeof value && value && value.__esModule) return value;
var ns = Object.create(null);
if (__webpack_require__.r(ns), Object.defineProperty(ns, "default", {
enumerable: !0,
value: value
}), 2 & mode && "string" != typeof value) for (var key in value) __webpack_require__.d(ns, key, function(key) {
return value[key];
}.bind(null, key));
return ns;
}, __webpack_require__.n = function(module) {
var getter = module && module.__esModule ? function() {
return module.default;
} : function() {
return module;
};
return __webpack_require__.d(getter, "a", getter), getter;
}, __webpack_require__.o = function(object, property) {
return Object.prototype.hasOwnProperty.call(object, property);
}, __webpack_require__.p = "", __webpack_require__(__webpack_require__.s = 0);
}([ function(module, exports, __webpack_require__) {
$("body").css("background", "#212121"), GM_addStyle(__webpack_require__(1).toString());
}, function(module, exports, __webpack_require__) {
(module.exports = __webpack_require__(2)(!1)).push([ module.i, "body{font-size:2rem;display:-webkit-box;display:-webkit-flex;display:-moz-box;display:-ms-flexbox;display:flex}div{background-color:#fff}", "" ]);
}, function(module, exports, __webpack_require__) {
"use strict";
module.exports = function(useSourceMap) {
var list = [];
return list.toString = function() {
return this.map(function(item) {
var content = function(item, useSourceMap) {
var content = item[1] || "", cssMapping = item[3];
if (!cssMapping) return content;
if (useSourceMap && "function" == typeof btoa) {
var sourceMapping = (sourceMap = cssMapping, "/*# sourceMappingURL=data:application/json;charset=utf-8;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + " */"), sourceURLs = cssMapping.sources.map(function(source) {
return "/*# sourceURL=" + cssMapping.sourceRoot + source + " */";
});
return [ content ].concat(sourceURLs).concat([ sourceMapping ]).join("\n");
}
var sourceMap;
return [ content ].join("\n");
}(item, useSourceMap);
return item[2] ? "@media " + item[2] + "{" + content + "}" : content;
}).join("");
}, list.i = function(modules, mediaQuery) {
"string" == typeof modules && (modules = [ [ null, modules, "" ] ]);
for (var alreadyImportedModules = {}, i = 0; i < this.length; i++) {
var id = this[i][0];
null != id && (alreadyImportedModules[id] = !0);
}
for (i = 0; i < modules.length; i++) {
var item = modules[i];
null != item[0] && alreadyImportedModules[item[0]] || (mediaQuery && !item[2] ? item[2] = mediaQuery : mediaQuery && (item[2] = "(" + item[2] + ") and (" + mediaQuery + ")"),
list.push(item));
}
}, list;
};
} ]);
50 changes: 50 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const gulp = require('gulp'),
prettier = require('gulp-prettier'),
webpack = require('webpack'),
moment = require('moment');
const colors = require('colors');

const paths = {
js: {
all: ['./javascript/**/*.js', './*.js']
}
};

gulp.task('format:js', () => {
return gulp
.src(paths.js.all)
.pipe(prettier())
.pipe(gulp.dest((file) => file.base));
});

gulp.task('format', gulp.series('format:js'));

gulp.task('webpack', (callback) =>
webpack(require('./webpack.config'), (err, stats) => {
callback();
if (err) console.log(err);
console.log(
`[${colors.grey(`${moment().format('HH:mm:ss')}`)}][${colors.grey(
'Webpack'
)}] Build '${colors.cyan(stats.hash)}' after ${colors.magenta(
`${moment(stats.endTime).diff(moment(stats.startTime))}ms`
)}`
);
})
);
gulp.task('webpack:dev', () =>
webpack(require('./webpack.dev.config'), (err, stats) => {
if (err) console.log(err);
console.log(
`[${colors.grey(`${moment().format('HH:mm:ss')}`)}][${colors.grey(
'Webpack'
)}] Build '${colors.cyan(stats.hash)}' after ${colors.magenta(
`${moment(stats.endTime).diff(moment(stats.startTime))}ms`
)}`
);
})
);

gulp.task('build', gulp.series('webpack', 'format'));

gulp.task('default', gulp.series(gulp.parallel('webpack:dev')));
20 changes: 20 additions & 0 deletions header.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "PSN中文网功能增强",
"namespace": "https://github.com/swsoyee/psnine-enhanced-version",
"version": "1.0.0",
"description": "数折价格走势图,显示人民币价格,奖杯统计和筛选,发帖字数统计和即时预览,楼主高亮,自动翻页,屏蔽黑名单用户发言,被@用户的发言内容显示等多项功能优化P9体验",
"icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAMAAAAp4XiDAAAAMFBMVEVHcEw0mNs0mNs0mNs0mNs0mNs0mNs0mNs0mNs0mNs0mNs0mNs0mNs0mNs0mNs0mNuEOyNSAAAAD3RSTlMAQMAQ4PCApCBQcDBg0JD74B98AAABN0lEQVRIx+2WQRaDIAxECSACWLn/bdsCIkNQ2XXT2bTyHEx+glGIv4STU3KNRccp6dNh4qTM4VDLrGVRxbLGaa3ZQSVQulVJl5JFlh3cLdNyk/xe2IXz4DqYLhZ4mWtHd4/SLY/QQwKmWmGcmUfHb4O1mu8BIPGw4Hg1TEvySQGWoBcItgxndmsbhtJd6baukIKnt525W4anygNECVc1UD8uVbRNbumZNl6UmkagHeRJfX0BdM5NXgA+ZKESpiJ9tRFftZEvue2cS6cKOrGk/IOLTLUcaXuZHrZDq3FB2IonOBCHIy8Bs1Zzo1MxVH+m8fQ+nFeCQM3MWwEsWsy8e8Di7meA5Bb5MDYCt4SnUbP3lv1xOuWuOi3j5kJ5tPiZKahbi54anNRaaG7YElFKQBHR/9PjN3oD6fkt9WKF9rgAAAAASUVORK5CYII=",
"author": "InfinityLoop, mordom0404, Nathaniel_Wu, JayusTree",
"include": ["*psnine.com/*", "*d7vg.com/*"],
"require": [
"http://cdn.staticfile.org/jquery/2.1.4/jquery.min.js",
"https://code.highcharts.com/highcharts.js",
"https://code.highcharts.com/modules/histogram-bellcurve.js",
"https://unpkg.com/tippy.js@3/dist/tippy.all.min.js"
],
"license": "MIT",
"supportURL": "https://github.com/swsoyee/psnine-enhanced-version/issues/new",
"compatible": ["chrome", "firefox", "edge"],
"grant": ["GM_addStyle"],
"run-at": "document-start"
}
29 changes: 29 additions & 0 deletions monkey.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const header = require('./header');

const config = {
entry: './src/index.js'
};

module.exports.config = config;
module.exports.header = header;
module.exports.buildedHeader = () => {
const headerString = [];
headerString.push('// ==UserScript==');
for (let headerKey in header) {
if (Array.isArray(header[headerKey])) {
if (header[headerKey].length > 0) headerString.push('//');
for (let p in header[headerKey]) {
headerString.push(
'// @' + headerKey.padEnd(13) + header[headerKey][p]
);
}
} else {
headerString.push(
'// @' + headerKey.padEnd(13) + header[headerKey]
);
}
}
headerString.push('// ==/UserScript==');
headerString.push('');
return headerString.join('\n');
};
35 changes: 35 additions & 0 deletions monkey.dev.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const monkey = require('./monkey.config');
const header = monkey.header;

//The test path.
header.require.push(
'file://' +
__dirname +
'\\test\\' +
monkey.header.name.toLowerCase().replace(' ', '-') +
'.js'
);

module.exports.config = monkey.config;
module.exports.header = header;
module.exports.buildedHeader = () => {
const headerString = [];
headerString.push('// ==UserScript==');
for (let headerKey in header) {
if (Array.isArray(header[headerKey])) {
if (header[headerKey].length > 0) headerString.push('//');
for (let p in header[headerKey]) {
headerString.push(
'// @' + headerKey.padEnd(13) + header[headerKey][p]
);
}
} else {
headerString.push(
'// @' + headerKey.padEnd(13) + header[headerKey]
);
}
}
headerString.push('// ==/UserScript==');
headerString.push('');
return headerString.join('\n');
};
Loading