diff --git a/.oxlintrc.json b/.oxlintrc.json
index d9f0abc3a..5a132d5da 100644
--- a/.oxlintrc.json
+++ b/.oxlintrc.json
@@ -151,10 +151,11 @@
// "unicorn-js/better-dom-traversing": "error", false positive on cheerio
"unicorn/catch-error-name": "error",
"unicorn-js/class-reference-in-static-methods": "error",
- // "unicorn-js/comment-content": "error", re-evaluate when unicorn > 66.0.0
"unicorn/consistent-assert": "error",
+ // "unicorn-js/consistent-boolean-name": "error", // unopinionated
"unicorn-js/consistent-class-member-order": "error",
"unicorn-js/consistent-compound-words": "error",
+ "unicorn-js/consistent-conditional-object-spread": "error",
"unicorn/consistent-date-clone": "error",
"unicorn/consistent-empty-array-spread": "error",
"unicorn/consistent-existence-index-check": "error",
@@ -163,6 +164,7 @@
"unicorn-js/consistent-json-file-read": "error",
"unicorn-js/consistent-optional-chaining": "error",
"unicorn/consistent-template-literal-escape": "error",
+ "unicorn-js/default-export-style": "error",
"unicorn/empty-brace-spaces": "error",
"unicorn/error-message": "error",
"unicorn/escape-case": "error",
@@ -172,12 +174,16 @@
// "unicorn/filename-case": "error",
"unicorn/import-style": "error",
"unicorn-js/isolated-functions": "error",
+ "unicorn-js/logical-assignment-operators": "error",
"unicorn-js/max-nested-calls": "error",
+ // "unicorn-js/name-replacements": "error", // unopinionated, rebranded prevent-abbreviations
"unicorn/new-for-builtins": "error",
"unicorn/no-abusive-eslint-disable": "error",
"unicorn/no-accessor-recursion": "error",
+ "unicorn-js/no-accidental-bitwise-operator": "error",
"unicorn/no-anonymous-default-export": "error",
// "unicorn/no-array-callback-reference": "error",
+ "unicorn-js/no-array-concat-in-loop": "error",
"unicorn/no-array-fill-with-reference-type": "error",
"unicorn/no-array-for-each": "error",
"unicorn-js/no-array-from-fill": "error",
@@ -185,17 +191,26 @@
// "unicorn/no-array-reduce": "error",
"unicorn/no-array-reverse": "error",
// "unicorn/no-array-sort": "error",
+ "unicorn-js/no-array-sort-for-min-max": "error",
+ "unicorn-js/no-array-splice": "error",
// "unicorn/no-await-expression-member": "error",
"unicorn/no-await-in-promise-methods": "error",
"unicorn-js/no-blob-to-file": "error",
- // "unicorn-js/no-break-in-nested-loop": "error", unopinionated
+ "unicorn-js/no-boolean-sort-comparator": "error",
+ // "unicorn-js/no-break-in-nested-loop": "error", // unopinionated
// "unicorn-js/no-canvas-to-image": "error", // unused
+ "unicorn-js/no-chained-comparison": "error",
+ "unicorn-js/no-collection-bracket-access": "error",
"unicorn-js/no-computed-property-existence-check": "error",
"unicorn-js/no-confusing-array-splice": "error",
"unicorn-js/no-confusing-array-with": "error",
"unicorn/no-console-spaces": "error",
- // "unicorn-js/no-declarations-before-early-exit": "error", re-evaluate when unicorn > 66.0.0
+ "unicorn-js/no-constant-zero-expression": "error",
+ // "unicorn-js/no-declarations-before-early-exit": "error", // unopinionated
"unicorn/no-document-cookie": "error",
+ "unicorn-js/no-double-comparison": "error",
+ "unicorn-js/no-duplicate-if-branches": "error",
+ "unicorn-js/no-duplicate-logical-operands": "error",
"unicorn-js/no-duplicate-loops": "error",
"unicorn-js/no-duplicate-set-values": "error",
// "unicorn/no-empty-file": "error",
@@ -203,18 +218,21 @@
"unicorn-js/no-exports-in-scripts": "error",
// "unicorn/no-for-loop": "error", // won't be implemented
"unicorn-js/no-global-object-property-assignment": "error",
- // "unicorn/no-hex-escape": "error",
"unicorn/no-immediate-mutation": "error",
+ "unicorn-js/no-impossible-length-comparison": "error",
"unicorn-js/no-incorrect-query-selector": "error",
- // "unicorn-js/no-incorrect-template-string-interpolation": "error", too many false positives
+ // "unicorn-js/no-incorrect-template-string-interpolation": "error", // unopinionated, too many false positives in v68
"unicorn/no-instanceof-builtins": "error",
"unicorn-js/no-invalid-argument-count": "error",
+ "unicorn-js/no-invalid-character-comparison": "error",
"unicorn/no-invalid-fetch-options": "error",
"unicorn/no-invalid-remove-event-listener": "error",
"unicorn-js/no-late-current-target-access": "error",
"unicorn/no-lonely-if": "error",
+ "unicorn-js/no-loop-iterable-mutation": "error",
"unicorn/no-magic-array-flat-depth": "error",
"unicorn-js/no-mismatched-map-key": "error",
+ "unicorn-js/no-misrefactored-assignment": "error",
// "unicorn/no-named-default": "error", -> use import/no-named-default
"unicorn-js/no-negated-array-predicate": "error",
"unicorn-js/no-negated-comparison": "error",
@@ -225,6 +243,8 @@
// "unicorn/no-nested-ternary": "error",
"unicorn/no-new-array": "error",
"unicorn/no-new-buffer": "error",
+ "unicorn-js/no-non-function-verb-prefix": "error",
+ "unicorn-js/no-nonstandard-builtin-properties": "error",
// "unicorn/no-null": "error",
// "unicorn/no-object-as-default-parameter": "error",
"unicorn-js/no-object-methods-with-collections": "error",
@@ -232,64 +252,81 @@
// "unicorn/no-process-exit": "error",
"unicorn-js/no-redundant-comparison": "error",
"unicorn-js/no-return-array-push": "error",
+ "unicorn-js/no-selector-as-dom-name": "error",
"unicorn/no-single-promise-in-promise-methods": "error",
"unicorn/no-static-only-class": "error",
"unicorn-js/no-subtraction-comparison": "error",
"unicorn/no-thenable": "error",
"unicorn/no-this-assignment": "error",
"unicorn-js/no-this-outside-of-class": "error",
+ // "unicorn-js/no-top-level-assignment-in-function": "error", // unopinionated
// "unicorn-js/no-top-level-side-effects": "error", // allows dayjs.extend()
"unicorn/no-typeof-undefined": "error",
+ "unicorn-js/no-uncalled-method": "error",
"unicorn-js/no-undeclared-class-members": "error",
"unicorn/no-unnecessary-array-flat-depth": "error",
"unicorn/no-unnecessary-array-splice-count": "error",
"unicorn/no-unnecessary-await": "error",
+ "unicorn-js/no-unnecessary-boolean-comparison": "error",
"unicorn-js/no-unnecessary-global-this": "error",
"unicorn-js/no-unnecessary-nested-ternary": "error",
"unicorn-js/no-unnecessary-polyfills": "error",
"unicorn/no-unnecessary-slice-end": "error",
"unicorn-js/no-unnecessary-splice": "error",
"unicorn/no-unreadable-array-destructuring": "error",
+ "unicorn-js/no-unreadable-for-of-expression": "error",
"unicorn/no-unreadable-iife": "error",
- // "unicorn-js/no-unreadable-new-expression": "error", // allows new URL(x).href
"unicorn-js/no-unreadable-object-destructuring": "error",
"unicorn-js/no-unsafe-buffer-conversion": "error",
"unicorn-js/no-unsafe-property-key": "error",
"unicorn-js/no-unsafe-string-replacement": "error",
"unicorn-js/no-unused-array-method-return": "error",
"unicorn-js/no-useless-boolean-cast": "error",
+ "unicorn-js/no-useless-coercion": "error",
"unicorn/no-useless-collection-argument": "error",
+ "unicorn-js/no-useless-compound-assignment": "error",
"unicorn-js/no-useless-concat": "error",
+ "unicorn-js/no-useless-continue": "error",
+ "unicorn-js/no-useless-delete-check": "error",
"unicorn-js/no-useless-else": "error",
"unicorn/no-useless-error-capture-stack-trace": "error",
"unicorn/no-useless-fallback-in-spread": "error",
// "unicorn/no-useless-iterator-to-array": "error",
"unicorn/no-useless-length-check": "error",
+ "unicorn-js/no-useless-logical-operand": "error",
+ "unicorn-js/no-useless-override": "error",
"unicorn/no-useless-promise-resolve-reject": "error",
// "unicorn-js/no-useless-recursion": "error", unopinionated
"unicorn/no-useless-spread": "error",
// "unicorn/no-useless-switch-case": "error",
"unicorn-js/no-useless-template-literals": "error",
// "unicorn/no-useless-undefined": "error",
+ "unicorn-js/no-xor-as-exponentiation": "error",
"unicorn/no-zero-fractions": "error",
// "unicorn/number-literal-case": "error",
// "unicorn/numeric-separators-style": "error",
+ "unicorn-js/operator-assignment": "error",
"unicorn/prefer-add-event-listener": "error",
"unicorn-js/prefer-add-event-listener-options": "error",
"unicorn/prefer-array-find": "error",
"unicorn/prefer-array-flat": "error",
"unicorn/prefer-array-flat-map": "error",
+ "unicorn-js/prefer-array-from-async": "error",
"unicorn-js/prefer-array-from-map": "error",
"unicorn/prefer-array-index-of": "error",
+ "unicorn-js/prefer-array-iterable-methods": "error",
"unicorn-js/prefer-array-last-methods": "error",
+ "unicorn-js/prefer-array-slice": "error",
"unicorn/prefer-array-some": "error",
"unicorn/prefer-at": "error",
"unicorn-js/prefer-await": "error",
"unicorn/prefer-bigint-literals": "error",
"unicorn/prefer-blob-reading-methods": "error",
+ "unicorn-js/prefer-boolean-return": "error",
"unicorn/prefer-class-fields": "error",
"unicorn/prefer-classlist-toggle": "error",
// "unicorn/prefer-code-point": "error",
+ "unicorn-js/prefer-continue": "error",
"unicorn/prefer-date-now": "error",
"unicorn/prefer-default-parameters": "error",
"unicorn-js/prefer-direct-iteration": "error",
@@ -298,11 +335,15 @@
"unicorn/prefer-dom-node-remove": "error",
"unicorn/prefer-dom-node-text-content": "error",
"unicorn-js/prefer-early-return": "error",
+ "unicorn-js/prefer-else-if": "error",
"unicorn/prefer-event-target": "error",
"unicorn/prefer-export-from": "error",
+ "unicorn-js/prefer-flat-math-min-max": "error",
"unicorn-js/prefer-get-or-insert-computed": "error",
"unicorn-js/prefer-global-number-constants": "error",
// "unicorn/prefer-global-this": "error",
+ "unicorn-js/prefer-has-check": "error",
+ "unicorn-js/prefer-hoisting-branch-code": "error",
// "unicorn-js/prefer-https": "error",
"unicorn-js/prefer-identifier-import-export-specifiers": "error",
"unicorn/prefer-includes": "error",
@@ -313,10 +354,12 @@
"unicorn/prefer-keyboard-event-key": "error",
"unicorn-js/prefer-location-assign": "error",
"unicorn/prefer-logical-operator-over-ternary": "error",
+ "unicorn-js/prefer-map-from-entries": "error",
"unicorn-js/prefer-math-abs": "error",
+ "unicorn-js/prefer-math-constants": "error",
"unicorn/prefer-math-min-max": "error",
"unicorn/prefer-math-trunc": "error",
- // "unicorn-js/prefer-minimal-ternary": "error", re-evaluate when unicorn > 66.0.0
+ // "unicorn-js/prefer-minimal-ternary": "error", // unopinionated, fixes have less readability
"unicorn/prefer-modern-dom-apis": "error",
"unicorn/prefer-modern-math-apis": "error",
// "unicorn/prefer-module": "error",
@@ -333,6 +376,7 @@
"unicorn/prefer-optional-catch-binding": "error",
// "unicorn-js/prefer-path2d": "error", // unused
"unicorn-js/prefer-private-class-fields": "error",
+ "unicorn-js/prefer-promise-with-resolvers": "error",
"unicorn/prefer-prototype-methods": "error",
"unicorn/prefer-query-selector": "error",
"unicorn-js/prefer-queue-microtask": "error",
@@ -342,12 +386,13 @@
"unicorn-js/prefer-scoped-selector": "error",
"unicorn/prefer-set-has": "error",
"unicorn/prefer-set-size": "error",
- "unicorn-js/prefer-short-arrow-method": "error",
+ "unicorn-js/prefer-short-arrow-method": "warn",
"unicorn-js/prefer-simple-condition-first": "error",
"unicorn-js/prefer-simple-sort-comparator": "error",
"unicorn-js/prefer-single-array-predicate": "error",
"unicorn/prefer-single-call": "error",
"unicorn-js/prefer-single-object-destructuring": "error",
+ "unicorn-js/prefer-single-replace": "error",
"unicorn-js/prefer-smaller-scope": "error",
"unicorn-js/prefer-split-limit": "error",
// "unicorn/prefer-spread": "error",
@@ -366,7 +411,11 @@
"unicorn/prefer-type-error": "error",
"unicorn-js/prefer-type-literal-last": "error",
// "unicorn-js/prefer-uint8array-base64": "error", re-evaluate when node > 25
+ "unicorn-js/prefer-unary-minus": "error",
+ "unicorn-js/prefer-unicode-code-point-escapes": "error",
+ "unicorn-js/prefer-url-can-parse": "error",
"unicorn-js/prefer-url-href": "error",
+ "unicorn-js/prefer-while-loop-condition": "error",
// "unicorn/prevent-abbreviations": "error",
"unicorn/relative-url-style": "error",
"unicorn/require-array-join-separator": "error",
@@ -600,7 +649,6 @@
"unicorn/no-await-expression-member": "off",
"unicorn/no-empty-file": "warn",
// "unicorn/no-for-loop": "off", // won't be implemented
- "unicorn/no-hex-escape": "warn",
"unicorn/no-nested-ternary": "off",
"unicorn/no-null": "off",
"unicorn/no-object-as-default-parameter": "warn",
diff --git a/eslint-plugins/nsfw-flag.js b/eslint-plugins/nsfw-flag.js
index aed8717ad..a4cbc5eb1 100644
--- a/eslint-plugins/nsfw-flag.js
+++ b/eslint-plugins/nsfw-flag.js
@@ -147,20 +147,24 @@ export default eslintCompatPlugin({
// 查找 features 属性
for (const prop of routeObject.properties) {
- if (prop.type === 'Property' && prop.key && prop.key.name === 'features') {
- featuresProperty = prop;
-
- // 在 features 中查找 nsfw 属性
- if (prop.value && prop.value.type === 'ObjectExpression') {
- for (const featureProp of prop.value.properties) {
- if (featureProp.type === 'Property' && featureProp.key && featureProp.key.name === 'nsfw') {
- nsfwProperty = featureProp;
- break;
- }
- }
- }
- break;
+ if (!(prop.type === 'Property' && prop.key && prop.key.name === 'features')) {
+ continue;
}
+
+ featuresProperty = prop;
+
+ // 在 features 中查找 nsfw 属性
+ if (prop.value && prop.value.type === 'ObjectExpression') {
+ for (const featureProp of prop.value.properties) {
+ if (!(featureProp.type === 'Property' && featureProp.key && featureProp.key.name === 'nsfw')) {
+ continue;
+ }
+
+ nsfwProperty = featureProp;
+ break;
+ }
+ }
+ break;
}
// 检查是否需要添加或修复 nsfw 标志
diff --git a/lib/api/category/one.ts b/lib/api/category/one.ts
index e6f7d4266..60fb290c3 100644
--- a/lib/api/category/one.ts
+++ b/lib/api/category/one.ts
@@ -7,19 +7,21 @@ const categoryList: Record = {};
for (const namespace in namespaces) {
for (const path in namespaces[namespace].routes) {
- if (namespaces[namespace].routes[path].categories?.length) {
- for (const category of namespaces[namespace].routes[path].categories!) {
- if (!Object.hasOwn(categoryList, category)) {
- categoryList[category] = {};
- }
- if (!Object.hasOwn(categoryList[category], namespace)) {
- categoryList[category][namespace] = {
- ...namespaces[namespace],
- routes: {},
- };
- }
- categoryList[category][namespace].routes[path] = namespaces[namespace].routes[path];
+ if (!namespaces[namespace].routes[path].categories?.length) {
+ continue;
+ }
+ const categories = namespaces[namespace].routes[path].categories!;
+ for (const category of categories) {
+ if (!Object.hasOwn(categoryList, category)) {
+ categoryList[category] = {};
}
+ if (!Object.hasOwn(categoryList[category], namespace)) {
+ categoryList[category][namespace] = {
+ ...namespaces[namespace],
+ routes: {},
+ };
+ }
+ categoryList[category][namespace].routes[path] = namespaces[namespace].routes[path];
}
}
}
diff --git a/lib/errors/types/captcha.ts b/lib/errors/types/captcha.ts
index 46bc07e15..4df270d48 100644
--- a/lib/errors/types/captcha.ts
+++ b/lib/errors/types/captcha.ts
@@ -1,5 +1,3 @@
-class CaptchaError extends Error {
+export default class CaptchaError extends Error {
name = 'CaptchaError';
}
-
-export default CaptchaError;
diff --git a/lib/errors/types/config-not-found.ts b/lib/errors/types/config-not-found.ts
index c96cea03c..b8a3d2e14 100644
--- a/lib/errors/types/config-not-found.ts
+++ b/lib/errors/types/config-not-found.ts
@@ -1,5 +1,3 @@
-class ConfigNotFoundError extends Error {
+export default class ConfigNotFoundError extends Error {
name = 'ConfigNotFoundError';
}
-
-export default ConfigNotFoundError;
diff --git a/lib/errors/types/invalid-parameter.ts b/lib/errors/types/invalid-parameter.ts
index 8599ec4d2..482a65e80 100644
--- a/lib/errors/types/invalid-parameter.ts
+++ b/lib/errors/types/invalid-parameter.ts
@@ -1,5 +1,3 @@
-class InvalidParameterError extends Error {
+export default class InvalidParameterError extends Error {
name = 'InvalidParameterError';
}
-
-export default InvalidParameterError;
diff --git a/lib/errors/types/not-found.ts b/lib/errors/types/not-found.ts
index 9cba16b31..2c4687dac 100644
--- a/lib/errors/types/not-found.ts
+++ b/lib/errors/types/not-found.ts
@@ -1,5 +1,3 @@
-class NotFoundError extends Error {
+export default class NotFoundError extends Error {
name = 'NotFoundError';
}
-
-export default NotFoundError;
diff --git a/lib/errors/types/reject.ts b/lib/errors/types/reject.ts
index b6b91fe49..3e350672f 100644
--- a/lib/errors/types/reject.ts
+++ b/lib/errors/types/reject.ts
@@ -1,5 +1,3 @@
-class RejectError extends Error {
+export default class RejectError extends Error {
name = 'RejectError';
}
-
-export default RejectError;
diff --git a/lib/errors/types/request-in-progress.ts b/lib/errors/types/request-in-progress.ts
index 73ae4b570..aceb4bb08 100644
--- a/lib/errors/types/request-in-progress.ts
+++ b/lib/errors/types/request-in-progress.ts
@@ -1,5 +1,3 @@
-class RequestInProgressError extends Error {
+export default class RequestInProgressError extends Error {
name = 'RequestInProgressError';
}
-
-export default RequestInProgressError;
diff --git a/lib/middleware/anti-hotlink.test.ts b/lib/middleware/anti-hotlink.test.ts
index d718fad4c..fafc2fb04 100644
--- a/lib/middleware/anti-hotlink.test.ts
+++ b/lib/middleware/anti-hotlink.test.ts
@@ -272,7 +272,7 @@ const testAntiHotlink = async (path, expectObj, query?: string | Record `${key}=${value}`)
.join('&');
}
- path = path + (queryStr ? `?${queryStr}` : '');
+ path += (queryStr ? `?${queryStr}` : '');
const response = await app.request(path);
const parsed = await parser.parseString(await response.text());
diff --git a/lib/middleware/logger.ts b/lib/middleware/logger.ts
index 19b038aa3..64c77e817 100644
--- a/lib/middleware/logger.ts
+++ b/lib/middleware/logger.ts
@@ -12,13 +12,13 @@ enum LogPrefix {
const colorStatus = (status: number) => {
const out: { [key: string]: string } = {
- 7: `\u001B[35m${status}\u001B[0m`,
- 5: `\u001B[31m${status}\u001B[0m`,
- 4: `\u001B[33m${status}\u001B[0m`,
- 3: `\u001B[36m${status}\u001B[0m`,
- 2: `\u001B[32m${status}\u001B[0m`,
- 1: `\u001B[32m${status}\u001B[0m`,
- 0: `\u001B[33m${status}\u001B[0m`,
+ 7: `\u{1B}[35m${status}\u{1B}[0m`,
+ 5: `\u{1B}[31m${status}\u{1B}[0m`,
+ 4: `\u{1B}[33m${status}\u{1B}[0m`,
+ 3: `\u{1B}[36m${status}\u{1B}[0m`,
+ 2: `\u{1B}[32m${status}\u{1B}[0m`,
+ 1: `\u{1B}[32m${status}\u{1B}[0m`,
+ 0: `\u{1B}[33m${status}\u{1B}[0m`,
};
const calculateStatus = Math.trunc(status / 100);
diff --git a/lib/middleware/parameter-re2.test.ts b/lib/middleware/parameter-re2.test.ts
index 7cbabd69d..546ab1c63 100644
--- a/lib/middleware/parameter-re2.test.ts
+++ b/lib/middleware/parameter-re2.test.ts
@@ -2,16 +2,17 @@ import { describe, expect, it, vi } from 'vitest';
class FakeRE2 {
static CASE_INSENSITIVE = 1;
+
+ static compile(pattern: string) {
+ return new FakeRE2(pattern);
+ }
+
private pattern: string;
constructor(pattern: string) {
this.pattern = pattern;
}
- static compile(pattern: string) {
- return new FakeRE2(pattern);
- }
-
matcher(text: string) {
return {
find: () => text.includes(this.pattern),
diff --git a/lib/middleware/parameter.ts b/lib/middleware/parameter.ts
index ea5e81da8..ce7780cf2 100644
--- a/lib/middleware/parameter.ts
+++ b/lib/middleware/parameter.ts
@@ -74,11 +74,11 @@ const middleware: MiddlewareHandler = async (ctx, next) => {
}
// fix allowEmpty
- data.item = data.item || [];
+ data.item ||= [];
// decode HTML entities
- data.title && (data.title = entities.decodeXML(data.title + ''));
- data.description && (data.description = entities.decodeXML(data.description + ''));
+ data.title &&= entities.decodeXML(data.title + '');
+ data.description &&= entities.decodeXML(data.description + '');
// sort items
if (ctx.req.query('sorted') !== 'false') {
@@ -86,7 +86,7 @@ const middleware: MiddlewareHandler = async (ctx, next) => {
}
const handleItem = (item: DataItem) => {
- item.title && (item.title = entities.decodeXML(item.title + ''));
+ item.title &&= entities.decodeXML(item.title + '');
// handle pubDate
if (item.pubDate) {
@@ -227,15 +227,15 @@ const middleware: MiddlewareHandler = async (ctx, next) => {
}
if (ctx.req.query('filter_description')) {
const descriptionRegex = makeRegex(ctx.req.query('filter_description')!);
- isFilter = isFilter && (descriptionRegex instanceof RE2JS ? descriptionRegex.matcher(description).find() : !!descriptionRegex.test(description));
+ isFilter &&= descriptionRegex instanceof RE2JS ? descriptionRegex.matcher(description).find() : !!descriptionRegex.test(description);
}
if (ctx.req.query('filter_author')) {
const authorRegex = makeRegex(ctx.req.query('filter_author')!);
- isFilter = isFilter && (authorRegex instanceof RE2JS ? authorRegex.matcher(author).find() : !!authorRegex.test(author));
+ isFilter &&= authorRegex instanceof RE2JS ? authorRegex.matcher(author).find() : !!authorRegex.test(author);
}
if (ctx.req.query('filter_category')) {
const categoryRegex = makeRegex(ctx.req.query('filter_category')!);
- isFilter = isFilter && category.some((c) => (categoryRegex instanceof RE2JS ? categoryRegex.matcher(c).find() : c.match(categoryRegex)));
+ isFilter &&= category.some((c) => (categoryRegex instanceof RE2JS ? categoryRegex.matcher(c).find() : c.match(categoryRegex)));
}
return isFilter;
@@ -256,15 +256,15 @@ const middleware: MiddlewareHandler = async (ctx, next) => {
}
if (ctx.req.query('filterout') || ctx.req.query('filterout_description')) {
const descriptionRegex = makeRegex(ctx.req.query('filterout_description') || ctx.req.query('filterout')!);
- isFilter = isFilter && (descriptionRegex instanceof RE2JS ? !descriptionRegex.matcher(description).find() : !descriptionRegex.test(description));
+ isFilter &&= descriptionRegex instanceof RE2JS ? !descriptionRegex.matcher(description).find() : !descriptionRegex.test(description);
}
if (ctx.req.query('filterout_author')) {
const authorRegex = makeRegex(ctx.req.query('filterout_author')!);
- isFilter = isFilter && (authorRegex instanceof RE2JS ? !authorRegex.matcher(author).find() : !authorRegex.test(author));
+ isFilter &&= authorRegex instanceof RE2JS ? !authorRegex.matcher(author).find() : !authorRegex.test(author);
}
if (ctx.req.query('filterout_category')) {
const categoryRegex = makeRegex(ctx.req.query('filterout_category')!);
- isFilter = isFilter && category.every((c) => !(categoryRegex instanceof RE2JS ? categoryRegex.matcher(c).find() : c.match(categoryRegex)));
+ isFilter &&= category.every((c) => !(categoryRegex instanceof RE2JS ? categoryRegex.matcher(c).find() : c.match(categoryRegex)));
}
return isFilter;
@@ -406,10 +406,12 @@ const middleware: MiddlewareHandler = async (ctx, next) => {
if (num.test(ctx.req.query('brief')!)) {
const brief: number = Number.parseInt(ctx.req.query('brief')!);
for (const item of data.item) {
- if (item.description) {
- const text = sanitizeHtml(item.description, { allowedTags: [], allowedAttributes: {} });
- item.description = text.length > brief ? `${text.slice(0, brief)}…
` : `${text}
`;
+ if (!item.description) {
+ continue;
}
+
+ const text = sanitizeHtml(item.description, { allowedTags: [], allowedAttributes: {} });
+ item.description = text.length > brief ? `${text.slice(0, brief)}…
` : `${text}
`;
}
} else {
throw new Error('Invalid parameter brief. Please check the doc https://docs.rsshub.app/guide/parameters#shu-chu-jian-xun');
diff --git a/lib/middleware/template.tsx b/lib/middleware/template.tsx
index 1b3038ad3..ecc947ee5 100644
--- a/lib/middleware/template.tsx
+++ b/lib/middleware/template.tsx
@@ -36,8 +36,8 @@ const middleware: MiddlewareHandler = async (ctx, next) => {
if (data) {
data.title = collapseWhitespace(data.title) || '';
- data.description && (data.description = collapseWhitespace(data.description) || '');
- data.author && (data.author = collapseWhitespace(data.author) || '');
+ data.description &&= collapseWhitespace(data.description) || '';
+ data.author &&= collapseWhitespace(data.author) || '';
if (data.item) {
for (const item of data.item) {
@@ -59,7 +59,7 @@ const middleware: MiddlewareHandler = async (ctx, next) => {
// remove unicode control characters
// see #14940 #14943 #15262
// oxlint-disable-next-line no-control-regex
- item.description = item.description.replaceAll(/[\u0000-\u0009\v\f\u000E-\u001F\u007F\u200B\uFFFF]/g, '');
+ item.description = item.description.replaceAll(/[\u{0000}-\u{0009}\v\f\u{000E}-\u{001F}\u{007F}\u{200B}\u{FFFF}]/gu, '');
}
if (typeof item.author === 'string') {
@@ -81,12 +81,12 @@ const middleware: MiddlewareHandler = async (ctx, next) => {
if (outputType !== 'rss') {
try {
- item.pubDate && (item.pubDate = convertDateToISO8601(item.pubDate) || '');
+ item.pubDate &&= convertDateToISO8601(item.pubDate) || '';
} catch {
item.pubDate = '';
}
try {
- item.updated && (item.updated = convertDateToISO8601(item.updated) || '');
+ item.updated &&= convertDateToISO8601(item.updated) || '';
} catch {
item.updated = '';
}
diff --git a/lib/routes/005/index.tsx b/lib/routes/005/index.tsx
index 166d73015..734edf37c 100644
--- a/lib/routes/005/index.tsx
+++ b/lib/routes/005/index.tsx
@@ -67,7 +67,7 @@ export const handler = async (ctx) => {
item.title = title;
item.description = description;
- item.pubDate = timezone(parseDate($$('.time').text()), +8);
+ item.pubDate = timezone(parseDate($$('.time').text()), 8);
item.category = $$('meta[name="keywords"]').prop('content').split(/,/);
item.content = {
html: description,
diff --git a/lib/routes/0818tuan/index.ts b/lib/routes/0818tuan/index.ts
index a6df25136..39fcc7f56 100644
--- a/lib/routes/0818tuan/index.ts
+++ b/lib/routes/0818tuan/index.ts
@@ -55,7 +55,7 @@ async function handler(ctx) {
$('.pageLink, .alert, p[style="margin:15px;"]').remove();
item.description = $('.post-content').html();
- item.pubDate = timezone(parseDate($('.panel-body > .text-center').text().replace('时间:', ''), 'YYYY-MM-DD HH:mm:ss'), +8);
+ item.pubDate = timezone(parseDate($('.panel-body > .text-center').text().replace('时间:', ''), 'YYYY-MM-DD HH:mm:ss'), 8);
return item;
})
diff --git a/lib/routes/163/exclusive.ts b/lib/routes/163/exclusive.ts
index ef265de1b..881efdb75 100644
--- a/lib/routes/163/exclusive.ts
+++ b/lib/routes/163/exclusive.ts
@@ -134,7 +134,7 @@ async function handler(ctx) {
title: item.title,
author: item.source,
link: item.skipURL || item.url || `${rootUrl}/dy/article/${item.docid}.html`,
- pubDate: timezone(parseDate(item.ptime), +8),
+ pubDate: timezone(parseDate(item.ptime), 8),
videoId: item.skipType === 'video' ? item.stitle : '',
}));
diff --git a/lib/routes/163/today.ts b/lib/routes/163/today.ts
index d259642ce..5ccefa862 100644
--- a/lib/routes/163/today.ts
+++ b/lib/routes/163/today.ts
@@ -48,7 +48,7 @@ async function handler(ctx) {
let items = response.data.data.items.map((item) => ({
title: item.title,
author: item.source,
- pubDate: timezone(parseDate(item.ptime), +8),
+ pubDate: timezone(parseDate(item.ptime), 8),
description: `${item.digest}
`,
link: item.url || `https://c.m.163.com/news/a/${item.docid}.html`,
}));
diff --git a/lib/routes/18comic/search.ts b/lib/routes/18comic/search.ts
index ffd8324b8..3b9a81c78 100644
--- a/lib/routes/18comic/search.ts
+++ b/lib/routes/18comic/search.ts
@@ -56,7 +56,7 @@ async function handler(ctx) {
let apiUrl = getApiUrl();
order = time === 'a' ? order : `${order}_${time}`;
- apiUrl = `${apiUrl}/search?search_query=${encodedKeyword}&o=${order}`;
+ apiUrl += `/search?search_query=${encodedKeyword}&o=${order}`;
const apiResult = await processApiItems(apiUrl);
let filteredItemsByCategory = apiResult.content;
// Filter items by category if not 'all'
diff --git a/lib/routes/19lou/index.ts b/lib/routes/19lou/index.ts
index fb5be0179..00c01289a 100644
--- a/lib/routes/19lou/index.ts
+++ b/lib/routes/19lou/index.ts
@@ -100,7 +100,7 @@ async function handler(ctx) {
item.author = content('.uname, .user-name').first().text();
item.description = content('.post-cont').first().html() || content('.thread-cont').html();
- item.pubDate = timezone(parseDate(content('.cont-top-left meta').first().attr('content')), +8);
+ item.pubDate = timezone(parseDate(content('.cont-top-left meta').first().attr('content')), 8);
return item;
})
diff --git a/lib/routes/1lou/index.ts b/lib/routes/1lou/index.ts
index abc54f06b..166c57a10 100644
--- a/lib/routes/1lou/index.ts
+++ b/lib/routes/1lou/index.ts
@@ -34,7 +34,7 @@ export const handler = async (ctx) => {
return {
title: subjectEl.text(),
- pubDate: timezone(parseDate(item.find('span.date').text()), +8),
+ pubDate: timezone(parseDate(item.find('span.date').text()), 8),
link: new URL(subjectEl.prop('href'), rootUrl).href,
category: [
item.find('a.text-secondary').text().replaceAll('[]', ''),
@@ -63,7 +63,7 @@ export const handler = async (ctx) => {
item.title = title;
item.description = description;
- item.pubDate = timezone(parseDate($$('span.date').text()), +8);
+ item.pubDate = timezone(parseDate($$('span.date').text()), 8);
item.category = $$('a.badge')
.toArray()
.map((c) => $$(c).text());
diff --git a/lib/routes/2048/index.tsx b/lib/routes/2048/index.tsx
index 4cf967857..6feaef974 100644
--- a/lib/routes/2048/index.tsx
+++ b/lib/routes/2048/index.tsx
@@ -143,7 +143,7 @@ async function handler(ctx) {
});
item.author = content('.fl.black').first().text();
- item.pubDate = timezone(parseDate(content('span.fl.gray').first().attr('title')), +8);
+ item.pubDate = timezone(parseDate(content('span.fl.gray').first().attr('title')), 8);
const readTpc = content('#read_tpc').first();
const copyLink = content('#copytext')?.first()?.text();
diff --git a/lib/routes/21caijing/channel.ts b/lib/routes/21caijing/channel.ts
index 1cecf429a..f0e235293 100644
--- a/lib/routes/21caijing/channel.ts
+++ b/lib/routes/21caijing/channel.ts
@@ -101,7 +101,7 @@ export const handler = async (ctx: Context): Promise => {
const processedItem: DataItem = {
title,
- pubDate: pubDate ? timezone(parseRelativeDate(pubDate), +8) : undefined,
+ pubDate: pubDate ? timezone(parseRelativeDate(pubDate), 8) : undefined,
link: linkUrl,
category: categories,
author: authors,
@@ -141,13 +141,13 @@ export const handler = async (ctx: Context): Promise => {
const processedItem: DataItem = {
title,
description,
- pubDate: pubDateStr ? timezone(parseDate(pubDateStr), +8) : item.pubDate,
+ pubDate: pubDateStr ? timezone(parseDate(pubDateStr), 8) : item.pubDate,
category: categories,
content: {
html: description,
text: description,
},
- updated: upDatedStr ? timezone(parseDate(upDatedStr), +8) : item.updated,
+ updated: upDatedStr ? timezone(parseDate(upDatedStr), 8) : item.updated,
language,
};
diff --git a/lib/routes/2cycd/index.ts b/lib/routes/2cycd/index.ts
index 5a5ad7cf1..4b52e7599 100644
--- a/lib/routes/2cycd/index.ts
+++ b/lib/routes/2cycd/index.ts
@@ -53,7 +53,7 @@ async function handler(ctx) {
const first_post = content('td[id^="postmessage_"]').first();
const dateobj = content('em[id^="authorposton"]').first();
item.description = first_post.html();
- item.pubDate = timezone(parseDate(dateobj.find('span').attr('title'), 'YYYY-M-D HH:mm:ss'), +8);
+ item.pubDate = timezone(parseDate(dateobj.find('span').attr('title'), 'YYYY-M-D HH:mm:ss'), 8);
return item;
})
diff --git a/lib/routes/36kr/hot-list.ts b/lib/routes/36kr/hot-list.ts
index 3c48333cb..7712bdcc6 100644
--- a/lib/routes/36kr/hot-list.ts
+++ b/lib/routes/36kr/hot-list.ts
@@ -56,7 +56,7 @@ const getProperty = (object, key) => {
let result = object;
const keys = key.split('.');
for (const k of keys) {
- result = result && result[k];
+ result &&= result[k];
}
return result;
};
diff --git a/lib/routes/4chan/utils.tsx b/lib/routes/4chan/utils.tsx
index f961ef8ec..7ad52002c 100644
--- a/lib/routes/4chan/utils.tsx
+++ b/lib/routes/4chan/utils.tsx
@@ -35,11 +35,7 @@ const processCatalog = ({ data, board, viewOptions }: { data: CatalogApiReturn;
return false;
}
- if (viewOptions.maxReplies !== undefined && replies > viewOptions.maxReplies) {
- return false;
- }
-
- return true;
+ return !(viewOptions.maxReplies !== undefined && replies > viewOptions.maxReplies);
})
.map((thread) => ({
author: `${thread.name} ${thread.trip ?? thread.no}`,
diff --git a/lib/routes/4ksj/forum.tsx b/lib/routes/4ksj/forum.tsx
index 91c10204a..f4f811c68 100644
--- a/lib/routes/4ksj/forum.tsx
+++ b/lib/routes/4ksj/forum.tsx
@@ -182,9 +182,9 @@ async function handler(ctx) {
const title = l.contents().first().text();
const link = l.next().prop('href') ?? l.nextUntil('a').next().prop('href');
- item.enclosure_url = item.enclosure_url ?? link;
- item.enclosure_type = item.enclosure_type ?? 'application/x-bittorrent';
- item.enclosure_title = item.enclosure_title ?? title;
+ item.enclosure_url ??= link;
+ item.enclosure_type ??= 'application/x-bittorrent';
+ item.enclosure_title ??= title;
return {
title,
@@ -237,7 +237,7 @@ async function handler(ctx) {
info: $$('div.nex_drama_sums').html(),
links,
});
- item.pubDate = timezone(parseDate(pubDate, 'YYYY-M-D HH:mm:ss'), +8);
+ item.pubDate = timezone(parseDate(pubDate, 'YYYY-M-D HH:mm:ss'), 8);
item.category = Object.values(mergedDetails)
.flatMap((c) => c.split(/\s/))
.filter(Boolean);
diff --git a/lib/routes/50forum/zhuanjia.ts b/lib/routes/50forum/zhuanjia.ts
index c5687eb29..4251b4c60 100644
--- a/lib/routes/50forum/zhuanjia.ts
+++ b/lib/routes/50forum/zhuanjia.ts
@@ -46,7 +46,7 @@ async function handler() {
return {
title: keyword[1],
author: keyword[2],
- pubDate: timezone(parseDate(keyword[3], 'YYYY-MM-DD'), +8),
+ pubDate: timezone(parseDate(keyword[3], 'YYYY-MM-DD'), 8),
link,
};
});
diff --git a/lib/routes/51cto/recommend.ts b/lib/routes/51cto/recommend.ts
index 27f78306c..ee8b1b85b 100644
--- a/lib/routes/51cto/recommend.ts
+++ b/lib/routes/51cto/recommend.ts
@@ -53,7 +53,7 @@ async function getFullcontent(item, cookie = '') {
return {
title: item.title,
link: item.url,
- pubDate: parseDate(item.pubdate, +8),
+ pubDate: parseDate(item.pubdate, 8),
description: fullContent || item.abstract, // Return item.abstract if fullContent is null
};
}
diff --git a/lib/routes/52hrtt/index.ts b/lib/routes/52hrtt/index.ts
index 76cc9a6b3..ece291d5b 100644
--- a/lib/routes/52hrtt/index.ts
+++ b/lib/routes/52hrtt/index.ts
@@ -52,7 +52,7 @@ async function handler(ctx) {
.map((item) => ({
title: item.infoTitle,
author: item.quoteFrom,
- pubDate: timezone(parseDate(item.infoStartTime), +8),
+ pubDate: timezone(parseDate(item.infoStartTime), 8),
link: `${rootUrl}/${area}/n/w/info/${item.infoCentreId}`,
}));
diff --git a/lib/routes/52hrtt/symposium.ts b/lib/routes/52hrtt/symposium.ts
index b8c568479..d2ffd22f1 100644
--- a/lib/routes/52hrtt/symposium.ts
+++ b/lib/routes/52hrtt/symposium.ts
@@ -62,7 +62,7 @@ async function handler(ctx) {
.map((item) => ({
title: item.infoTitle,
author: item.quoteFrom,
- pubDate: timezone(parseDate(item.infoStartTime), +8),
+ pubDate: timezone(parseDate(item.infoStartTime), 8),
link: `${rootUrl}/global/n/w/info/${item.infoCentreId}`,
}));
diff --git a/lib/routes/56kog/util.tsx b/lib/routes/56kog/util.tsx
index 0673e0227..e0b67ece7 100644
--- a/lib/routes/56kog/util.tsx
+++ b/lib/routes/56kog/util.tsx
@@ -79,7 +79,7 @@ const fetchItems = async (limit, currentUrl, tryGet) => {
item.author = details.find((detail) => detail.label === '作者').value;
item.category = [details.find((detail) => detail.label === '状态').value, details.find((detail) => detail.label === '类型').value.text].filter(Boolean);
item.guid = `56kog-${item.link.match(/\/(\d+)\.html$/)[1]}#${pubDate}`;
- item.pubDate = timezone(parseDate(pubDate), +8);
+ item.pubDate = timezone(parseDate(pubDate), 8);
} catch {
// no-empty
}
diff --git a/lib/routes/69shu/article.ts b/lib/routes/69shu/article.ts
index c38d92ded..b01f21322 100644
--- a/lib/routes/69shu/article.ts
+++ b/lib/routes/69shu/article.ts
@@ -70,7 +70,8 @@ const parseObject = (reg: RegExp, str: string): Record => {
const obj = {};
const match = reg.exec(str);
if (match) {
- for (const line of match[0].matchAll(/(\w+):\s?["']?([\s\S]+?)["']?[\n,}]/g)) {
+ const matchedLines = match[0].matchAll(/(\w+):\s?["']?([\s\S]+?)["']?[\n,}]/g);
+ for (const line of matchedLines) {
obj[line[1]] = line[2];
}
}
@@ -91,7 +92,7 @@ const decrypt = (txt: string, articleid: string, chapterid: string, decryptionMa
}
return txt
- .replaceAll(/\u2003|\n/g, '')
+ .replaceAll(/\u{2003}|\n/gu, '')
.split('
')
.flatMap((line, index, array) => {
const mapped = lineMap[index];
diff --git a/lib/routes/6park/index.ts b/lib/routes/6park/index.ts
index e3904f8f9..fd6123acc 100644
--- a/lib/routes/6park/index.ts
+++ b/lib/routes/6park/index.ts
@@ -67,7 +67,7 @@ async function handler(ctx) {
item.title = content('title').text().replace(' -6park.com', '');
item.author = detailResponse.data.match(/送交者:[^>]*>([^<]*)<\/a>/)[1].trim();
- item.pubDate = timezone(parseDate(detailResponse.data.match(/于 (.*) 已读/)[1], 'YYYY-MM-DD h:m'), +8);
+ item.pubDate = timezone(parseDate(detailResponse.data.match(/于 (.*) 已读/)[1], 'YYYY-MM-DD h:m'), 8);
item.description = content('pre')
.html()
.replaceAll('', '')
diff --git a/lib/routes/6park/news.ts b/lib/routes/6park/news.ts
index 30941bde8..c6d53cb59 100644
--- a/lib/routes/6park/news.ts
+++ b/lib/routes/6park/news.ts
@@ -80,7 +80,7 @@ async function handler(ctx) {
item.title = content('h2').text();
item.author = matches[1].trim();
- item.pubDate = timezone(parseDate(matches[2], 'YYYY-MM-DD h:m'), +8);
+ item.pubDate = timezone(parseDate(matches[2], 'YYYY-MM-DD h:m'), 8);
item.description = content('#shownewsc').html().replaceAll('', '');
} catch {
// no-empty
diff --git a/lib/routes/6v123/utils.ts b/lib/routes/6v123/utils.ts
index f4e8bab90..7ea686a78 100644
--- a/lib/routes/6v123/utils.ts
+++ b/lib/routes/6v123/utils.ts
@@ -42,7 +42,7 @@ export async function processItems(ctx, baseURL, exclude) {
list.map((item) => {
const link = $(item).find('a');
const href = link.attr('href');
- const pubDate = timezone(parseDate($(item).find('span').text().replaceAll(/[[\]]/g, ''), 'MM-DD'), +8);
+ const pubDate = timezone(parseDate($(item).find('span').text().replaceAll(/[[\]]/g, ''), 'MM-DD'), 8);
const text = link.text();
if (href === undefined) {
diff --git a/lib/routes/78dm/index.ts b/lib/routes/78dm/index.ts
index 1fb95b2de..fdebe8826 100644
--- a/lib/routes/78dm/index.ts
+++ b/lib/routes/78dm/index.ts
@@ -49,7 +49,7 @@ export const handler = async (ctx) => {
return {
title,
description,
- pubDate: pubDate && /\d{4}(?:\.\d{2}){2}\s\d{2}:\d{2}/.test(pubDate) ? timezone(parseDate(pubDate, 'YYYY.MM.DD HH:mm'), +8) : undefined,
+ pubDate: pubDate && /\d{4}(?:\.\d{2}){2}\s\d{2}:\d{2}/.test(pubDate) ? timezone(parseDate(pubDate, 'YYYY.MM.DD HH:mm'), 8) : undefined,
link: href?.startsWith('//') ? `https:${href}` : href,
category: [
...new Set([
@@ -104,7 +104,7 @@ export const handler = async (ctx) => {
item.title = title;
item.description = description;
- item.pubDate = timezone(parseDate($$('p.push-time').text().split(/:/).pop()), +8);
+ item.pubDate = timezone(parseDate($$('p.push-time').text().split(/:/).pop()), 8);
item.author = $$('a.push-username').contents().first().text();
item.content = {
html: description,
diff --git a/lib/routes/81/81rc/index.ts b/lib/routes/81/81rc/index.ts
index b9f6b974b..18bdf4f9a 100644
--- a/lib/routes/81/81rc/index.ts
+++ b/lib/routes/81/81rc/index.ts
@@ -27,7 +27,7 @@ export const handler = async (ctx) => {
return {
title: item.find('a').text(),
- pubDate: timezone(parseDate(item.find('span').text()), +8),
+ pubDate: timezone(parseDate(item.find('span').text()), 8),
link: item.find('a').prop('href'),
language,
};
@@ -44,7 +44,7 @@ export const handler = async (ctx) => {
item.title = $$('h2').text();
item.description = description;
- item.pubDate = timezone(parseDate($$('div.time span').last().text()), +8);
+ item.pubDate = timezone(parseDate($$('div.time span').last().text()), 8);
item.author = $$('div.time span').first().text();
item.content = {
html: description,
diff --git a/lib/routes/8264/list.tsx b/lib/routes/8264/list.tsx
index 1ff231569..3a752f13e 100644
--- a/lib/routes/8264/list.tsx
+++ b/lib/routes/8264/list.tsx
@@ -145,7 +145,7 @@ async function handler(ctx) {
item.category = content('div.fl_dh a, div.site a')
.toArray()
.map((c) => content(c).text().trim());
- item.pubDate = timezone(parseDate(pubDate, ['YYYY-MM-DD HH:mm', 'YYYY-M-D HH:mm']), +8);
+ item.pubDate = timezone(parseDate(pubDate, ['YYYY-MM-DD HH:mm', 'YYYY-M-D HH:mm']), 8);
return item;
})
diff --git a/lib/routes/9to5/subsite.ts b/lib/routes/9to5/subsite.ts
index 2695c7559..eefa7f300 100644
--- a/lib/routes/9to5/subsite.ts
+++ b/lib/routes/9to5/subsite.ts
@@ -41,10 +41,10 @@ async function handler(ctx) {
}
if (ctx.req.param('tag')) {
- link = `${link}/guides/${ctx.req.param('tag')}/feed/`;
+ link += `/guides/${ctx.req.param('tag')}/feed/`;
title = `${ctx.req.param('tag')} | ${title}`;
} else {
- link = `${link}/feed/`;
+ link += '/feed/';
}
const feed = await parser.parseURL(link);
diff --git a/lib/routes/a9vg/index.ts b/lib/routes/a9vg/index.ts
index a38a32455..5259262cb 100644
--- a/lib/routes/a9vg/index.ts
+++ b/lib/routes/a9vg/index.ts
@@ -43,7 +43,7 @@ export const handler = async (ctx) => {
]
: undefined,
}),
- pubDate: timezone(parseDate(item.find('div.a9-rich-card-list_infos').text()), +8),
+ pubDate: timezone(parseDate(item.find('div.a9-rich-card-list_infos').text()), 8),
language,
};
});
@@ -95,7 +95,7 @@ export const handler = async (ctx) => {
.match(/发表于 (\d+-\d+-\d+ \d+:\d+)/)?.[1] ?? $$('span.c-article-main_content-intro-item').first().text(),
['YYYY-M-D HH:mm', 'YYYY-MM-DD HH:mm']
),
- +8
+ 8
);
item.language = language;
diff --git a/lib/routes/abc/index.ts b/lib/routes/abc/index.ts
index 7c1c969a9..dbcd8dfc3 100644
--- a/lib/routes/abc/index.ts
+++ b/lib/routes/abc/index.ts
@@ -56,7 +56,7 @@ async function handler(ctx) {
const $ = load(currentResponse);
- documentId = documentId ?? $('div[data-uri^="coremedia://collection/"]').first().prop('data-uri').split(/\//).pop();
+ documentId ??= $('div[data-uri^="coremedia://collection/"]').first().prop('data-uri').split(/\//).pop();
const response = await ofetch(apiUrl, {
query: {
diff --git a/lib/routes/acpaa/index.ts b/lib/routes/acpaa/index.ts
index b33d67603..77976aa56 100644
--- a/lib/routes/acpaa/index.ts
+++ b/lib/routes/acpaa/index.ts
@@ -44,7 +44,7 @@ async function handler(ctx) {
return {
title: item.prop('title'),
link: new URL(item.prop('href'), rootUrl).href,
- pubDate: timezone(parseDate(item.find('span[title]').prop('title')), +8),
+ pubDate: timezone(parseDate(item.find('span[title]').prop('title')), 8),
};
});
diff --git a/lib/routes/adquan/case-library.ts b/lib/routes/adquan/case-library.ts
index 5264e229d..096685cee 100644
--- a/lib/routes/adquan/case-library.ts
+++ b/lib/routes/adquan/case-library.ts
@@ -81,14 +81,14 @@ export const handler = async (ctx: Context): Promise => {
const processedItem: DataItem = {
title,
description,
- pubDate: pubDateStr ? timezone(parseDate(pubDateStr), +8) : item.pubDate,
+ pubDate: pubDateStr ? timezone(parseDate(pubDateStr), 8) : item.pubDate,
category: categories,
author: authors,
content: {
html: description,
text: description,
},
- updated: upDatedStr ? timezone(parseDate(upDatedStr), +8) : item.updated,
+ updated: upDatedStr ? timezone(parseDate(upDatedStr), 8) : item.updated,
language,
};
diff --git a/lib/routes/adquan/index.ts b/lib/routes/adquan/index.ts
index aef56ed7e..a739a7cf4 100644
--- a/lib/routes/adquan/index.ts
+++ b/lib/routes/adquan/index.ts
@@ -81,14 +81,14 @@ export const handler = async (ctx: Context): Promise => {
const processedItem: DataItem = {
title,
description,
- pubDate: pubDateStr ? timezone(parseDate(pubDateStr), +8) : item.pubDate,
+ pubDate: pubDateStr ? timezone(parseDate(pubDateStr), 8) : item.pubDate,
category: categories,
author: authors,
content: {
html: description,
text: description,
},
- updated: upDatedStr ? timezone(parseDate(upDatedStr), +8) : item.updated,
+ updated: upDatedStr ? timezone(parseDate(upDatedStr), 8) : item.updated,
language,
};
diff --git a/lib/routes/agri/index.ts b/lib/routes/agri/index.ts
index 308c0cb87..de2d4248a 100644
--- a/lib/routes/agri/index.ts
+++ b/lib/routes/agri/index.ts
@@ -72,7 +72,7 @@ export const handler = async (ctx) => {
item.title = title;
item.description = description;
- item.pubDate = timezone(parseDate($$('meta[name="publishdate"]').prop('content')), +8);
+ item.pubDate = timezone(parseDate($$('meta[name="publishdate"]').prop('content')), 8);
item.author = $$('meta[name="author"]').prop('content') || $$('meta[name="source"]').prop('content');
item.content = {
html: description,
diff --git a/lib/routes/ahjzu/news.ts b/lib/routes/ahjzu/news.ts
index f3f663645..4ee5ad425 100644
--- a/lib/routes/ahjzu/news.ts
+++ b/lib/routes/ahjzu/news.ts
@@ -54,7 +54,7 @@ async function handler() {
return {
title: item.find('a').attr('title'),
link,
- pubDate: timezone(parseDate(date), +8),
+ pubDate: timezone(parseDate(date), 8),
};
});
diff --git a/lib/routes/aibase/topic.ts b/lib/routes/aibase/topic.ts
index c7e6c623f..e9a445caa 100644
--- a/lib/routes/aibase/topic.ts
+++ b/lib/routes/aibase/topic.ts
@@ -22,7 +22,7 @@ export const handler = async (ctx) => {
data: { results: apiTagProcs },
} = await ofetch(apiTagProcUrl, {
query: {
- ...(id ? { tag: id } : {}),
+ ...(id && { tag: id }),
page: 1,
pagesize: 20,
f: filter,
diff --git a/lib/routes/aibase/util.tsx b/lib/routes/aibase/util.tsx
index 19364d0d3..72724c270 100644
--- a/lib/routes/aibase/util.tsx
+++ b/lib/routes/aibase/util.tsx
@@ -91,7 +91,7 @@ const processItems = (items: any[]): any[] =>
return {
title,
description,
- pubDate: timezone(parseDate(item.addtime), +8),
+ pubDate: timezone(parseDate(item.addtime), 8),
link: new URL(`tool/${item.zurl}`, rootUrl).href,
category: [...new Set([...strToArray(item.categories), ...strToArray(item.tags), item.catname, item.procattrname, item.procformname, item.proctypename])].filter(Boolean),
guid,
diff --git a/lib/routes/aip/journal-pupp.ts b/lib/routes/aip/journal-pupp.ts
index 3e0412b5a..5372bfb3d 100644
--- a/lib/routes/aip/journal-pupp.ts
+++ b/lib/routes/aip/journal-pupp.ts
@@ -61,4 +61,5 @@ const handler = async (ctx) => {
allowEmpty: true,
};
};
+// TODO: missing route export
export default handler;
diff --git a/lib/routes/air-level/levelrank.ts b/lib/routes/air-level/levelrank.ts
index de24aca9b..c2391f913 100644
--- a/lib/routes/air-level/levelrank.ts
+++ b/lib/routes/air-level/levelrank.ts
@@ -37,9 +37,7 @@ async function handler(ctx) {
if (status === 'best') {
title = titleBest;
table = ``;
- }
-
- if (status === 'worsest') {
+ } else if (status === 'worsest') {
title = titleWorst;
table = ``;
}
diff --git a/lib/routes/aisixiang/column.ts b/lib/routes/aisixiang/column.ts
index 537bec3e9..af373beaa 100644
--- a/lib/routes/aisixiang/column.ts
+++ b/lib/routes/aisixiang/column.ts
@@ -50,7 +50,7 @@ async function handler(ctx) {
title: a.text(),
link: new URL(a.prop('href'), rootUrl).href,
author: a.text().split(':', 1)[0],
- pubDate: timezone(parseDate(item.find('span').text()), +8),
+ pubDate: timezone(parseDate(item.find('span').text()), 8),
};
});
diff --git a/lib/routes/aisixiang/utils.ts b/lib/routes/aisixiang/utils.ts
index 84fc1e56b..2521fca4b 100644
--- a/lib/routes/aisixiang/utils.ts
+++ b/lib/routes/aisixiang/utils.ts
@@ -28,7 +28,7 @@ const ProcessFeed = (limit, tryGet, items) =>
.find('u')
.toArray()
.map((c) => content(c).text());
- item.pubDate = timezone(parseDate(content('div.info').text().split('时间:').pop()), +8);
+ item.pubDate = timezone(parseDate(content('div.info').text().split('时间:').pop()), 8);
item.upvotes = content('span.like-num').text() ? Number(content('span.like-num').text()) : 0;
item.comments = commentMatches ? Number(commentMatches[1]) : 0;
diff --git a/lib/routes/aisixiang/zhuanti.ts b/lib/routes/aisixiang/zhuanti.ts
index de3175a73..2ecf4e9c0 100644
--- a/lib/routes/aisixiang/zhuanti.ts
+++ b/lib/routes/aisixiang/zhuanti.ts
@@ -53,7 +53,7 @@ async function handler(ctx) {
title: a.text(),
link: new URL(a.prop('href'), rootUrl).href,
author: a.text().split(':', 1)[0],
- pubDate: timezone(parseDate(item.find('span').text()), +8),
+ pubDate: timezone(parseDate(item.find('span').text()), 8),
};
});
diff --git a/lib/routes/ali213/news.ts b/lib/routes/ali213/news.ts
index 1fd9538f7..bdb7b6442 100644
--- a/lib/routes/ali213/news.ts
+++ b/lib/routes/ali213/news.ts
@@ -134,7 +134,7 @@ export const handler = async (ctx: Context): Promise => {
...item,
title,
description,
- pubDate: timezone(parseDate($$('div.newstag_l').text().split(/\s/, 1)[0]), +8),
+ pubDate: timezone(parseDate($$('div.newstag_l').text().split(/\s/, 1)[0]), 8),
content: {
html: description,
text: $$('div#Content').html() ?? '',
diff --git a/lib/routes/aliresearch/information.ts b/lib/routes/aliresearch/information.ts
index 2baf52a7c..79df0c446 100644
--- a/lib/routes/aliresearch/information.ts
+++ b/lib/routes/aliresearch/information.ts
@@ -52,7 +52,7 @@ async function handler(ctx) {
let items = response.data.data.slice(0, limit).map((item) => ({
title: item.articleCode,
author: item.author,
- pubDate: timezone(parseDate(item.gmtCreated), +8),
+ pubDate: timezone(parseDate(item.gmtCreated), 8),
link: `${rootUrl}/ch/information/informationdetails?articleCode=${item.articleCode}`,
}));
diff --git a/lib/routes/aliyun/notice.ts b/lib/routes/aliyun/notice.ts
index f86cb0b64..027bf7452 100644
--- a/lib/routes/aliyun/notice.ts
+++ b/lib/routes/aliyun/notice.ts
@@ -55,7 +55,7 @@ async function handler(ctx) {
const title = element.find('a').text().trim();
const link = 'https://help.aliyun.com' + element.find('a').attr('href').trim();
const date = element.find('.y-right').text();
- const pubDate = timezone(parseDate(date), +8);
+ const pubDate = timezone(parseDate(date), 8);
return {
title,
description: '',
diff --git a/lib/routes/ally/rail.ts b/lib/routes/ally/rail.ts
index 8f5d6dbc5..2d18beac5 100644
--- a/lib/routes/ally/rail.ts
+++ b/lib/routes/ally/rail.ts
@@ -47,7 +47,7 @@ async function handler(ctx) {
const linkText = $(link).text();
title = title ? `${title} - ${linkText}` : linkText;
}
- title = title || (category && topic ? `${category} - ${topic}` : category) || '首页';
+ title ||= (category && topic ? `${category} - ${topic}` : category) || '首页';
let links = [
// list page: http://rail.ally.net.cn/html/lujuzixun/
$('.left .hynewsO h2 a').toArray(),
@@ -106,7 +106,7 @@ async function handler(ctx) {
let innerHtml;
if (child.name === 'div') {
innerHtml = $child.html();
- innerHtml = innerHtml && innerHtml.trim();
+ innerHtml &&= innerHtml.trim();
description += !innerHtml || innerHtml === ' ' ? (description ? '
' : '') : innerHtml;
} else {
// bare text node or something else
diff --git a/lib/routes/anquanke/category.ts b/lib/routes/anquanke/category.ts
index 2da6a9349..90911962e 100644
--- a/lib/routes/anquanke/category.ts
+++ b/lib/routes/anquanke/category.ts
@@ -48,7 +48,7 @@ async function handler(ctx) {
return content('#js-article').html();
})
: item.desc,
- pubDate: timezone(parseDate(item.date), +8),
+ pubDate: timezone(parseDate(item.date), 8),
link: art_url,
author: item.author.nickname,
};
diff --git a/lib/routes/anquanke/vul.ts b/lib/routes/anquanke/vul.ts
index 1ecdf681a..7a30a7f38 100644
--- a/lib/routes/anquanke/vul.ts
+++ b/lib/routes/anquanke/vul.ts
@@ -34,4 +34,5 @@ const handler = async () => {
};
};
+// TODO: missing route export
export default handler;
diff --git a/lib/routes/apiseven/blog.ts b/lib/routes/apiseven/blog.ts
index eb53f4bcd..af685ff6f 100644
--- a/lib/routes/apiseven/blog.ts
+++ b/lib/routes/apiseven/blog.ts
@@ -19,7 +19,7 @@ async function getArticles() {
return json.props.pageProps.list.map((item) => ({
title: item.title,
link: 'https://www.apiseven.com' + item.slug,
- pubDate: timezone(parseDate(item.published_at), +8),
+ pubDate: timezone(parseDate(item.published_at), 8),
category: item.tags,
}));
}
diff --git a/lib/routes/appstorrent/programs.tsx b/lib/routes/appstorrent/programs.tsx
index ced480153..009ca2d29 100644
--- a/lib/routes/appstorrent/programs.tsx
+++ b/lib/routes/appstorrent/programs.tsx
@@ -98,7 +98,7 @@ async function handler(ctx?: Context): Promise {
return {
title: $('title').text(),
- link: currentUrl.toString(),
+ link: currentUrl,
allowEmpty: true,
item: items,
};
diff --git a/lib/routes/asmr-200/index.tsx b/lib/routes/asmr-200/index.tsx
index 7916bf48d..7a97941a7 100644
--- a/lib/routes/asmr-200/index.tsx
+++ b/lib/routes/asmr-200/index.tsx
@@ -85,7 +85,7 @@ export const route: Route = {
image: each.mainCoverUrl,
author: each.name,
link: `https://asmr-200.com/work/${each.source_id}`,
- pubDate: timezone(parseDate(each.release, 'YYYY-MM-DD'), +8),
+ pubDate: timezone(parseDate(each.release, 'YYYY-MM-DD'), 8),
category,
description: render(each, `https://asmr-200.com/work/${each.source_id}`),
};
diff --git a/lib/routes/atcoder/post.ts b/lib/routes/atcoder/post.ts
index 55130f768..18e2ff937 100644
--- a/lib/routes/atcoder/post.ts
+++ b/lib/routes/atcoder/post.ts
@@ -46,7 +46,7 @@ async function handler(ctx) {
title: item.find('.panel-title').text(),
description: item.find('.panel-body').html(),
link: `${rootUrl}${item.find('.panel-title a').attr('href')}`,
- pubDate: timezone(parseDate(item.find('.timeago').attr('datetime')), +9),
+ pubDate: timezone(parseDate(item.find('.timeago').attr('datetime')), 9),
};
});
diff --git a/lib/routes/auto-stats/index.ts b/lib/routes/auto-stats/index.ts
index 36bd61d41..dd9b81d8e 100644
--- a/lib/routes/auto-stats/index.ts
+++ b/lib/routes/auto-stats/index.ts
@@ -53,7 +53,7 @@ async function handler(ctx) {
return {
title: title.replace(/●/, '').split(/(\d+/, 1)[0],
link: new URL(item.parent().prop('href'), rootUrl).href,
- pubDate: timezone(parseDate(pubDate, 'YYYY/M/D H:mm:ss'), +8),
+ pubDate: timezone(parseDate(pubDate, 'YYYY/M/D H:mm:ss'), 8),
};
});
diff --git a/lib/routes/bad/index.ts b/lib/routes/bad/index.ts
index 74fcfe60b..0bd8050db 100644
--- a/lib/routes/bad/index.ts
+++ b/lib/routes/bad/index.ts
@@ -52,7 +52,7 @@ async function handler(ctx) {
link: a.attr('href'),
description: item.find('.coverdiv').html(),
author: item.find('.author').text().trim(),
- pubDate: timezone(parseDate(item.find('time').attr('datetime')), +8),
+ pubDate: timezone(parseDate(item.find('time').attr('datetime')), 8),
category: item
.find('.label')
.toArray()
diff --git a/lib/routes/baidu/tieba/forum.tsx b/lib/routes/baidu/tieba/forum.tsx
index 9c001b7e5..9433fa3e0 100644
--- a/lib/routes/baidu/tieba/forum.tsx
+++ b/lib/routes/baidu/tieba/forum.tsx
@@ -72,7 +72,7 @@ async function handler(ctx) {
作者:{author_name}
>
),
- pubDate: timezone(parseDate(time, ['HH:mm', 'M-D', 'YYYY-MM'], true), +8),
+ pubDate: timezone(parseDate(time, ['HH:mm', 'M-D', 'YYYY-MM'], true), 8),
link: `https://tieba.baidu.com/p/${id}`,
};
});
diff --git a/lib/routes/baidu/tieba/post.tsx b/lib/routes/baidu/tieba/post.tsx
index cfc0a02dd..32eea6f95 100644
--- a/lib/routes/baidu/tieba/post.tsx
+++ b/lib/routes/baidu/tieba/post.tsx
@@ -98,7 +98,7 @@ async function handler(ctx) {
{from}
>
),
- pubDate: timezone(parseDate(time, 'YYYY-MM-DD hh:mm'), +8),
+ pubDate: timezone(parseDate(time, 'YYYY-MM-DD hh:mm'), 8),
link: `https://tieba.baidu.com/p/${id}?pid=${content.post_id}#${content.post_id}`,
};
}),
diff --git a/lib/routes/baidu/tieba/search.tsx b/lib/routes/baidu/tieba/search.tsx
index 537559918..9b8e5810c 100644
--- a/lib/routes/baidu/tieba/search.tsx
+++ b/lib/routes/baidu/tieba/search.tsx
@@ -88,7 +88,7 @@ async function handler(ctx) {
>
),
author,
- pubDate: timezone(parseDate(time, 'YYYY-MM-DD HH:mm'), +8),
+ pubDate: timezone(parseDate(time, 'YYYY-MM-DD HH:mm'), 8),
link,
};
}),
diff --git a/lib/routes/baidu/tieba/user.ts b/lib/routes/baidu/tieba/user.ts
index d757866eb..4a806ebb5 100644
--- a/lib/routes/baidu/tieba/user.ts
+++ b/lib/routes/baidu/tieba/user.ts
@@ -45,7 +45,7 @@ async function handler(ctx) {
imgurl = item.find('ul.n_media.clearfix img').attr('original');
return {
title: item.find('div.thread_name a').attr('title'),
- pubDate: timezone(parseDate(item.parent().find('div .n_post_time').text(), ['YYYY-MM-DD', 'HH:mm']), +8),
+ pubDate: timezone(parseDate(item.parent().find('div .n_post_time').text(), ['YYYY-MM-DD', 'HH:mm']), 8),
description: `${item.find('div.n_txt').text()}
`,
link: item.find('div.thread_name a').attr('href'),
};
diff --git a/lib/routes/bangumi.tv/calendar/_base.ts b/lib/routes/bangumi.tv/calendar/_base.ts
index 140b9da62..a06945bba 100644
--- a/lib/routes/bangumi.tv/calendar/_base.ts
+++ b/lib/routes/bangumi.tv/calendar/_base.ts
@@ -1,7 +1,7 @@
import { config } from '@/config';
import got from '@/utils/got';
-const getData = (tryGet) => {
+export const getData = (tryGet) => {
const bgmCalendarUrl = 'https://api.bgm.tv/calendar';
const bgmDataUrl = 'https://cdn.jsdelivr.net/npm/bangumi-data/dist/data.json';
@@ -35,4 +35,3 @@ const getData = (tryGet) => {
)
);
};
-export default getData;
diff --git a/lib/routes/bangumi.tv/calendar/today.tsx b/lib/routes/bangumi.tv/calendar/today.tsx
index f04b2f146..c33f9ec20 100644
--- a/lib/routes/bangumi.tv/calendar/today.tsx
+++ b/lib/routes/bangumi.tv/calendar/today.tsx
@@ -3,7 +3,7 @@ import { renderToString } from 'hono/jsx/dom/server';
import type { Route } from '@/types';
import cache from '@/utils/cache';
-import getData from './_base';
+import { getData } from './_base';
export const route: Route = {
path: '/calendar/today',
diff --git a/lib/routes/bangumi.tv/group/reply.ts b/lib/routes/bangumi.tv/group/reply.ts
index 9e2aa1a48..3c5834102 100644
--- a/lib/routes/bangumi.tv/group/reply.ts
+++ b/lib/routes/bangumi.tv/group/reply.ts
@@ -63,7 +63,7 @@ async function handler(ctx) {
title,
description: $('.postTopic .topic_content').html(),
author: $('.postTopic .inner strong a').first().text(),
- pubDate: timezone(parseDate($('.postTopic .re_info small').text().trim().slice(5)), +8),
+ pubDate: timezone(parseDate($('.postTopic .re_info small').text().trim().slice(5)), 8),
link,
};
@@ -74,7 +74,7 @@ async function handler(ctx) {
...finalLatestReplies.map((c) => ({
title: `${c.author} 回复了小组话题《${title}》`,
description: c.content,
- pubDate: timezone(parseDate(c.date), +8),
+ pubDate: timezone(parseDate(c.date), 8),
author: c.author,
link: `${link}#${c.id}`,
})),
diff --git a/lib/routes/bangumi.tv/subject/comments.ts b/lib/routes/bangumi.tv/subject/comments.ts
index f3d1e76d2..aa325f006 100644
--- a/lib/routes/bangumi.tv/subject/comments.ts
+++ b/lib/routes/bangumi.tv/subject/comments.ts
@@ -3,7 +3,7 @@ import { load } from 'cheerio';
import ofetch from '@/utils/ofetch';
import { parseDate, parseRelativeDate } from '@/utils/parse-date';
-const getComments = async (subjectID, minLength) => {
+export const getComments = async (subjectID, minLength) => {
// bangumi.tv未提供获取“吐槽(comments)”的API,因此仍需要通过抓取网页来获取
const link = `https://bgm.tv/subject/${subjectID}/comments`;
const html = await ofetch(link);
@@ -46,4 +46,3 @@ const getComments = async (subjectID, minLength) => {
})),
};
};
-export default getComments;
diff --git a/lib/routes/bangumi.tv/subject/ep.tsx b/lib/routes/bangumi.tv/subject/ep.tsx
index fe54c6f94..a70047fab 100644
--- a/lib/routes/bangumi.tv/subject/ep.tsx
+++ b/lib/routes/bangumi.tv/subject/ep.tsx
@@ -6,7 +6,7 @@ import { parseDate } from '@/utils/parse-date';
import { getLocalName } from './utils';
-const getEps = async (subjectID, showOriginalName) => {
+export const getEps = async (subjectID, showOriginalName) => {
const url = `https://api.bgm.tv/subject/${subjectID}?responseGroup=large`;
const epsInfo = await ofetch(url);
const activeEps = epsInfo.eps.filter((e) => e.status === 'Air');
@@ -28,4 +28,3 @@ const getEps = async (subjectID, showOriginalName) => {
})),
};
};
-export default getEps;
diff --git a/lib/routes/bangumi.tv/subject/index.ts b/lib/routes/bangumi.tv/subject/index.ts
index dbf9c7dd8..6b145a419 100644
--- a/lib/routes/bangumi.tv/subject/index.ts
+++ b/lib/routes/bangumi.tv/subject/index.ts
@@ -2,9 +2,9 @@ import InvalidParameterError from '@/errors/types/invalid-parameter';
import type { Route } from '@/types';
import { queryToBoolean } from '@/utils/readable-social';
-import getComments from './comments';
-import getEps from './ep';
-import getFromAPI from './offcial-subject-api';
+import { getComments } from './comments';
+import { getEps } from './ep';
+import { getFromAPI } from './offcial-subject-api';
export const route: Route = {
path: '/subject/:id/:type?/:showOriginalName?',
diff --git a/lib/routes/bangumi.tv/subject/offcial-subject-api.ts b/lib/routes/bangumi.tv/subject/offcial-subject-api.ts
index 703beba30..6f43072d3 100644
--- a/lib/routes/bangumi.tv/subject/offcial-subject-api.ts
+++ b/lib/routes/bangumi.tv/subject/offcial-subject-api.ts
@@ -3,7 +3,7 @@ import { parseDate } from '@/utils/parse-date';
import { getLocalName } from './utils';
-const getFromAPI = (type) => {
+export const getFromAPI = (type) => {
const mapping = {
blog: {
en: 'reviews',
@@ -32,4 +32,3 @@ const getFromAPI = (type) => {
};
};
};
-export default getFromAPI;
diff --git a/lib/routes/banyuetan/index.ts b/lib/routes/banyuetan/index.ts
index b522e8496..b8055ebb8 100644
--- a/lib/routes/banyuetan/index.ts
+++ b/lib/routes/banyuetan/index.ts
@@ -99,7 +99,7 @@ export const handler = async (ctx: Context): Promise => {
const processedItem: DataItem = {
title,
description,
- pubDate: pubDateStr ? timezone(parseDate(pubDateStr), +8) : item.pubDate,
+ pubDate: pubDateStr ? timezone(parseDate(pubDateStr), 8) : item.pubDate,
category: categories,
author: authors,
content: {
@@ -108,7 +108,7 @@ export const handler = async (ctx: Context): Promise => {
},
image,
banner: image,
- updated: upDatedStr ? timezone(parseDate(upDatedStr), +8) : item.updated,
+ updated: upDatedStr ? timezone(parseDate(upDatedStr), 8) : item.updated,
language,
};
diff --git a/lib/routes/baobua/article.ts b/lib/routes/baobua/article.ts
index 82fe3bdf7..25cefa9db 100644
--- a/lib/routes/baobua/article.ts
+++ b/lib/routes/baobua/article.ts
@@ -3,7 +3,7 @@ import { load } from 'cheerio';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
-async function loadArticle(link) {
+export const loadArticle = async (link) => {
const resp = await got(link);
const article = load(resp.body);
@@ -47,6 +47,4 @@ async function loadArticle(link) {
pubDate,
link,
};
-}
-
-export default loadArticle;
+};
diff --git a/lib/routes/baobua/category.ts b/lib/routes/baobua/category.ts
index 0618fd7dc..a764c987d 100644
--- a/lib/routes/baobua/category.ts
+++ b/lib/routes/baobua/category.ts
@@ -4,7 +4,7 @@ import type { Route } from '@/types';
import cache from '@/utils/cache';
import got from '@/utils/got';
-import loadArticle from './article';
+import { loadArticle } from './article';
import { SUB_NAME_PREFIX, SUB_URL } from './const';
export const route: Route = {
diff --git a/lib/routes/baobua/latest.ts b/lib/routes/baobua/latest.ts
index 0fc235ff7..23fed0300 100644
--- a/lib/routes/baobua/latest.ts
+++ b/lib/routes/baobua/latest.ts
@@ -4,7 +4,7 @@ import type { Route } from '@/types';
import cache from '@/utils/cache';
import got from '@/utils/got';
-import loadArticle from './article';
+import { loadArticle } from './article';
import { SUB_NAME_PREFIX, SUB_URL } from './const';
export const route: Route = {
diff --git a/lib/routes/baobua/search.ts b/lib/routes/baobua/search.ts
index 11d62506b..29dd7ac0a 100644
--- a/lib/routes/baobua/search.ts
+++ b/lib/routes/baobua/search.ts
@@ -4,7 +4,7 @@ import type { Route } from '@/types';
import cache from '@/utils/cache';
import got from '@/utils/got';
-import loadArticle from './article';
+import { loadArticle } from './article';
import { SUB_NAME_PREFIX, SUB_URL } from './const';
export const route: Route = {
diff --git a/lib/routes/barronschina/index.ts b/lib/routes/barronschina/index.ts
index 92f860ad5..800533227 100644
--- a/lib/routes/barronschina/index.ts
+++ b/lib/routes/barronschina/index.ts
@@ -68,7 +68,7 @@ async function handler(ctx) {
const content = load(detailResponse.data);
item.description = content('.cont_main').html();
- item.pubDate = timezone(parseDate(content('.timeTag').text()), +8);
+ item.pubDate = timezone(parseDate(content('.timeTag').text()), 8);
return item;
})
@@ -89,7 +89,7 @@ async function handler(ctx) {
title,
description,
link: currentUrl,
- pubDate: timezone(parseDate(`${item.parent().find('dt').text()} ${item.text()}`), +8),
+ pubDate: timezone(parseDate(`${item.parent().find('dt').text()} ${item.text()}`), 8),
};
});
diff --git a/lib/routes/bast/index.ts b/lib/routes/bast/index.ts
index 3b2c9e63c..ade47e473 100644
--- a/lib/routes/bast/index.ts
+++ b/lib/routes/bast/index.ts
@@ -66,7 +66,7 @@ async function handler(ctx) {
item.title = content('meta[name="ArticleTitle"]').attr('content');
item.author = content('meta[name="contentSource"]').attr('content');
- item.pubDate = timezone(parseDate(content('meta[name="pubdate"]').attr('content')), +8);
+ item.pubDate = timezone(parseDate(content('meta[name="pubdate"]').attr('content')), 8);
item.category = [content('meta[name="ColumnName"]').attr('content')];
item.description = content('.arccont').html();
diff --git a/lib/routes/bbc/utils.tsx b/lib/routes/bbc/utils.tsx
index 54b8a277e..a298262cf 100644
--- a/lib/routes/bbc/utils.tsx
+++ b/lib/routes/bbc/utils.tsx
@@ -50,7 +50,8 @@ type Block = {
const applyAttributes = (content: JSX.Element | string, attributes?: BlockAttribute[]): JSX.Element | string => {
let result: JSX.Element | string = content;
- for (const attribute of attributes ?? []) {
+ const attributeList = attributes ?? [];
+ for (const attribute of attributeList) {
switch (attribute) {
case 'bold':
result = {result};
diff --git a/lib/routes/bdys/index.tsx b/lib/routes/bdys/index.tsx
index b29f2ce2f..2e910f432 100644
--- a/lib/routes/bdys/index.tsx
+++ b/lib/routes/bdys/index.tsx
@@ -197,7 +197,7 @@ async function handler(ctx) {
>
);
- item.pubDate = timezone(parseDate(content('.bg-purple-lt').text().replace('更新时间:', '')), +8);
+ item.pubDate = timezone(parseDate(content('.bg-purple-lt').text().replace('更新时间:', '')), 8);
item.guid = `${item.link}#${content('.card h1').text()}`;
item.enclosure_url = torrents.html() ? `${rootUrl}${torrents.find('a').first().attr('href')}` : downloadResponse.data.pop().url;
diff --git a/lib/routes/behance/user.tsx b/lib/routes/behance/user.tsx
index 0bd133fcb..b936b7a69 100644
--- a/lib/routes/behance/user.tsx
+++ b/lib/routes/behance/user.tsx
@@ -164,7 +164,7 @@ async function handler(ctx) {
item.description = renderDescription(project.description, project.allModules);
item.category = [...new Set([...(item.category || []), ...(project.tags?.map((tag) => tag.title.toLowerCase()) || [])])];
- item.pubDate = item.pubDate || (project.publishedOn ? parseDate(project.publishedOn, 'X') : undefined);
+ item.pubDate ||= project.publishedOn ? parseDate(project.publishedOn, 'X') : undefined;
return item;
})
diff --git a/lib/routes/bendibao/news.ts b/lib/routes/bendibao/news.ts
index 4e863dc8c..aa0f41606 100644
--- a/lib/routes/bendibao/news.ts
+++ b/lib/routes/bendibao/news.ts
@@ -128,7 +128,7 @@ async function handler(ctx) {
.text()
.replace(/发布时间:/, '') ?? content('span.public_time').text()
),
- +8
+ 8
);
return item;
diff --git a/lib/routes/bilibili/cache.ts b/lib/routes/bilibili/cache.ts
index 6a86a7fe7..0aeaa6e92 100644
--- a/lib/routes/bilibili/cache.ts
+++ b/lib/routes/bilibili/cache.ts
@@ -123,7 +123,9 @@ const getWbiVerifyString = () => {
const array = JSON.parse(jsResponse.match(/\[(?:\d+,){63}\d+\]/));
const o = [];
for (const t of array) {
- r.charAt(t) && o.push(r.charAt(t));
+ if (r.charAt(t)) {
+ o.push(r.charAt(t));
+ }
}
return o.join('').slice(0, 32);
});
@@ -365,13 +367,11 @@ const getArticleDataFromCvid = async (cvid, uid) => {
description += `${text.word.words}
`;
}
}
- }
- if (element.para_type === 2) {
+ } else if (element.para_type === 2) {
for (const image of element.pic.pics) {
description += `
`;
}
- }
- if (element.para_type === 3 && element.line?.pic?.url) {
+ } else if (element.para_type === 3 && element.line?.pic?.url) {
description += `
`;
}
}
diff --git a/lib/routes/bilibili/live-area.ts b/lib/routes/bilibili/live-area.ts
index 40c356d03..dbcfaeb04 100644
--- a/lib/routes/bilibili/live-area.ts
+++ b/lib/routes/bilibili/live-area.ts
@@ -52,14 +52,16 @@ async function handler(ctx) {
for (const parentArea of nameResponse.data.data) {
for (const area of parentArea.list) {
- if (area.id === areaID) {
- parentTitle = parentArea.name;
- const parentID: string = parentArea.id;
- areaTitle = area.name;
- // cateID = area.cate_id;
- areaLink = `https://live.bilibili.com/p/eden/area-tags?parentAreaId=${parentID}&areaId=${areaID}`;
- break;
+ if (area.id !== areaID) {
+ continue;
}
+
+ parentTitle = parentArea.name;
+ const parentID: string = parentArea.id;
+ areaTitle = area.name;
+ // cateID = area.cate_id;
+ areaLink = `https://live.bilibili.com/p/eden/area-tags?parentAreaId=${parentID}&areaId=${areaID}`;
+ break;
}
}
diff --git a/lib/routes/bilibili/message-sessions.ts b/lib/routes/bilibili/message-sessions.ts
index 4ed8e5877..f2299d2e4 100644
--- a/lib/routes/bilibili/message-sessions.ts
+++ b/lib/routes/bilibili/message-sessions.ts
@@ -50,7 +50,7 @@ interface SessionItem {
ack_ts: number;
session_ts: number;
unread_count: number;
- last_msg: null | {
+ last_msg: {
sender_uid: number;
receiver_type: number;
receiver_id: number;
@@ -63,7 +63,7 @@ interface SessionItem {
msg_status: number;
notify_code: string;
msg_source: number;
- };
+ } | null;
group_type: number;
can_fold: number;
status: number;
diff --git a/lib/routes/bilibili/partion-ranking.ts b/lib/routes/bilibili/partion-ranking.ts
index 340148244..c827368a2 100644
--- a/lib/routes/bilibili/partion-ranking.ts
+++ b/lib/routes/bilibili/partion-ranking.ts
@@ -13,7 +13,7 @@ function formatDate(now) {
const year = now.getFullYear();
const month = now.getMonth() + 1;
const date = now.getDate();
- const dateTime = year + '' + (month >= 10 ? month : '0' + month) + '' + (date >= 10 ? date : '0' + date);
+ const dateTime = year + '' + (month >= 10 ? month : '0' + month) + (date >= 10 ? date : '0' + date);
return dateTime;
}
diff --git a/lib/routes/bilibili/wasm-exec.ts b/lib/routes/bilibili/wasm-exec.ts
index b1104767e..6c914e9db 100644
--- a/lib/routes/bilibili/wasm-exec.ts
+++ b/lib/routes/bilibili/wasm-exec.ts
@@ -173,7 +173,7 @@
throw new Error('globalThis.TextDecoder is not available, polyfill required');
}
- const encoder = new TextEncoder('utf-8');
+ const encoder = new TextEncoder();
const decoder = new TextDecoder('utf-8');
globalThis.Go = class {
diff --git a/lib/routes/binance/announcement.ts b/lib/routes/binance/announcement.ts
index 7c2b0dbea..ec1a407be 100644
--- a/lib/routes/binance/announcement.ts
+++ b/lib/routes/binance/announcement.ts
@@ -18,9 +18,9 @@ interface CatalogItem {
interface ArticleListResponse {
code: string;
- data: null | {
+ data: {
catalogs: CatalogItem[];
- };
+ } | null;
}
const TYPE_CATALOG_ID_MAP: Record = {
diff --git a/lib/routes/biquge/index.ts b/lib/routes/biquge/index.ts
index 4da457d8e..d2d27c128 100644
--- a/lib/routes/biquge/index.ts
+++ b/lib/routes/biquge/index.ts
@@ -51,7 +51,7 @@ async function handler(ctx) {
const $ = load(iconv.decode(response.data, encoding));
const author = $('meta[property="og:novel:author"]').attr('content');
- const pubDate = timezone(parseDate($('meta[property="og:novel:update_time"]').attr('content')), +8);
+ const pubDate = timezone(parseDate($('meta[property="og:novel:update_time"]').attr('content')), 8);
let items = $('dl dd a')
.toArray()
diff --git a/lib/routes/bjfu/it/utils.ts b/lib/routes/bjfu/it/utils.ts
index ef3517502..2998f726e 100644
--- a/lib/routes/bjfu/it/utils.ts
+++ b/lib/routes/bjfu/it/utils.ts
@@ -50,7 +50,7 @@ const ProcessFeed = (base, list, caches) =>
.text()
.match(/\d{4}-\d{2}-\d{2}/)
),
- +8
+ 8
);
// 使用tryGet方法从缓存获取内容。
diff --git a/lib/routes/bjfu/jwc/utils.ts b/lib/routes/bjfu/jwc/utils.ts
index c0e633eba..526bbda34 100644
--- a/lib/routes/bjfu/jwc/utils.ts
+++ b/lib/routes/bjfu/jwc/utils.ts
@@ -37,7 +37,7 @@ const ProcessFeed = (base, list, caches) =>
.text()
.match(/\d{4}-\d{2}-\d{2}/)
),
- +8
+ 8
);
// 使用tryGet方法从缓存获取内容。
diff --git a/lib/routes/bjfu/news/utils.ts b/lib/routes/bjfu/news/utils.ts
index 3511db1b2..b13dcc30b 100644
--- a/lib/routes/bjfu/news/utils.ts
+++ b/lib/routes/bjfu/news/utils.ts
@@ -20,7 +20,7 @@ async function loadContent(link) {
.text()
.match(/\d{4}(?:\/\d{2}){2}/)
),
- +8
+ 8
);
// 提取内容
diff --git a/lib/routes/bjnews/column.ts b/lib/routes/bjnews/column.ts
index 6529d9b3e..82723a8e5 100644
--- a/lib/routes/bjnews/column.ts
+++ b/lib/routes/bjnews/column.ts
@@ -29,8 +29,8 @@ async function handler(ctx) {
const list = res.data.slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 15).map((e) => ({
title: e.row.title,
guid: e.uuid,
- pubDate: timezone(parseDate(e.row.publish_time), +8),
- updated: timezone(parseDate(e.row.update_time), +8),
+ pubDate: timezone(parseDate(e.row.publish_time), 8),
+ updated: timezone(parseDate(e.row.update_time), 8),
link: `https://www.bjnews.com.cn/detail/${e.uuid}.html`,
}));
diff --git a/lib/routes/bjnews/utils.ts b/lib/routes/bjnews/utils.ts
index 86379eae1..1df79a8a2 100644
--- a/lib/routes/bjnews/utils.ts
+++ b/lib/routes/bjnews/utils.ts
@@ -11,7 +11,7 @@ export function fetchArticle(item) {
const $d = load(responses);
// $d('img').each((i, e) => $(e).attr('referrerpolicy', 'no-referrer'));
- item.pubDate = timezone(parseDate($d('.left-info .timer').text()), +8);
+ item.pubDate = timezone(parseDate($d('.left-info .timer').text()), 8);
item.author = $d('.left-info .reporter').text();
item.description = $d('#contentStr').html();
diff --git a/lib/routes/bjwxdxh/index.ts b/lib/routes/bjwxdxh/index.ts
index d8060cc9a..baec7979c 100644
--- a/lib/routes/bjwxdxh/index.ts
+++ b/lib/routes/bjwxdxh/index.ts
@@ -61,7 +61,7 @@ async function handler(ctx) {
.text()
.match(/作者:(\S*)\s+发布于:(\S*\s+.*?)\s/);
item.author = info[1];
- item.pubDate = timezone(parseDate(info[2], 'YYYY-MM-DD HH:mm:ss'), +8);
+ item.pubDate = timezone(parseDate(info[2], 'YYYY-MM-DD HH:mm:ss'), 8);
item.description = content('div#con').html().trim().replaceAll('\n', '');
return item;
})
diff --git a/lib/routes/bjx/huanbao.ts b/lib/routes/bjx/huanbao.ts
index 509014528..33ff748fc 100644
--- a/lib/routes/bjx/huanbao.ts
+++ b/lib/routes/bjx/huanbao.ts
@@ -89,7 +89,7 @@ const fetchPage = (link) =>
const item = {
title: $page('title').text(),
description: pages.map(($p) => $p('.cc-article').html() ?? '').join(''),
- pubDate: timezone(parseDate($page('.cc-headline .box p span').eq(0).text()), +8),
+ pubDate: timezone(parseDate($page('.cc-headline .box p span').eq(0).text()), 8),
link,
author: $page('.cc-headline .box p span').eq(1).text(),
};
diff --git a/lib/routes/bmkg/earthquake.ts b/lib/routes/bmkg/earthquake.ts
index d60f1dd89..18eb1bb9f 100644
--- a/lib/routes/bmkg/earthquake.ts
+++ b/lib/routes/bmkg/earthquake.ts
@@ -41,7 +41,7 @@ async function handler() {
return {
title: `${td[2].children[0].data}|${td[3].children[0].data}|${td[4].children[0].data}|${td[5].children[0].data}|${td[6].children[0].data}`,
link: url,
- pubDate: timezone(parseDate(`${td[1].children[0].data} ${td[1].children[2].data.slice(0, 8)}`, 'DD-MM-YY HH:mm:ss'), +7),
+ pubDate: timezone(parseDate(`${td[1].children[0].data} ${td[1].children[2].data.slice(0, 8)}`, 'DD-MM-YY HH:mm:ss'), 7),
};
});
diff --git a/lib/routes/bnext/index.ts b/lib/routes/bnext/index.ts
index 2c9848c16..e15734e4a 100644
--- a/lib/routes/bnext/index.ts
+++ b/lib/routes/bnext/index.ts
@@ -36,7 +36,7 @@ async function handler() {
const enclosure = item.enclosure;
const enclosure_url = enclosure?.url;
const enclosure_type = enclosure?.type;
- const enclosure_length = enclosure?.length ? Number(enclosure.length) : undefined;
+ const enclosure_length = enclosure?.length || undefined;
return {
title: item.title ?? item.link ?? 'Untitled',
diff --git a/lib/routes/bntnews/index.ts b/lib/routes/bntnews/index.ts
index aa117467e..eb0f25f7c 100644
--- a/lib/routes/bntnews/index.ts
+++ b/lib/routes/bntnews/index.ts
@@ -59,7 +59,7 @@ async function handler(ctx) {
title: article.title,
link,
description: article.content,
- pubDate: timezone(parseDate(article.firstPublishDate), +9),
+ pubDate: timezone(parseDate(article.firstPublishDate), 9),
author: article.reporter?.[0]?.name || '',
};
});
diff --git a/lib/routes/bse/index.ts b/lib/routes/bse/index.ts
index 0add93200..06cc8f30a 100644
--- a/lib/routes/bse/index.ts
+++ b/lib/routes/bse/index.ts
@@ -194,7 +194,7 @@ async function handler(ctx) {
category: item.tags,
description: item.text,
link: `${rootUrl}${item.htmlUrl}`,
- pubDate: timezone(parseDate(item.publishDate), +8),
+ pubDate: timezone(parseDate(item.publishDate), 8),
}));
break;
diff --git a/lib/routes/bsky/templates/post.tsx b/lib/routes/bsky/templates/post.tsx
index 4f7cf19a3..8d03535ed 100644
--- a/lib/routes/bsky/templates/post.tsx
+++ b/lib/routes/bsky/templates/post.tsx
@@ -17,11 +17,11 @@ type VideoEmbed = {
playlist?: string;
};
-type Embed = VideoEmbed & {
+type Embed = {
$type?: string;
images?: ImageEmbed[];
external?: ExternalEmbed;
-};
+} & VideoEmbed;
type PostProps = {
text?: string;
diff --git a/lib/routes/btzj/index.tsx b/lib/routes/btzj/index.tsx
index ef9fb00d0..711c1443c 100644
--- a/lib/routes/btzj/index.tsx
+++ b/lib/routes/btzj/index.tsx
@@ -145,7 +145,7 @@ async function handler(ctx) {
item.description = content('.post').html();
item.author = content('.purple, .grey').first().prev().text();
- item.pubDate = timezone(parseDate(content('.bg2 b').first().text()), +8);
+ item.pubDate = timezone(parseDate(content('.bg2 b').first().text()), 8);
if (torrents.length > 0) {
item.description += renderTorrents(torrents.toArray().map((t) => content(t).parent().html()));
diff --git a/lib/routes/buaa/jiaowu.ts b/lib/routes/buaa/jiaowu.ts
index 2bcfc4da5..21fe46e88 100644
--- a/lib/routes/buaa/jiaowu.ts
+++ b/lib/routes/buaa/jiaowu.ts
@@ -99,7 +99,7 @@ async function getList(url: string | URL, form: Record = {}) {
return {
title: $('a').text(),
link,
- pubDate: timezone(parseDate($('span.Floatright').text()), +8),
+ pubDate: timezone(parseDate($('span.Floatright').text()), 8),
};
})
.filter((item) => item !== null);
diff --git a/lib/routes/buaa/lib/space/newbook.tsx b/lib/routes/buaa/lib/space/newbook.tsx
index f9ffebe6f..1e548dc7a 100644
--- a/lib/routes/buaa/lib/space/newbook.tsx
+++ b/lib/routes/buaa/lib/space/newbook.tsx
@@ -234,7 +234,7 @@ async function getItem(item: Book): Promise {
return {
language: item.language === 'eng' ? 'en' : 'zh-CN',
title: item.title,
- pubDate: item.onSelfDate ? timezone(parseDate(item.onSelfDate), +8) : undefined,
+ pubDate: item.onSelfDate ? timezone(parseDate(item.onSelfDate), 8) : undefined,
description: content,
link,
};
diff --git a/lib/routes/buaa/news/index.ts b/lib/routes/buaa/news/index.ts
index ad88f8572..c8499f371 100644
--- a/lib/routes/buaa/news/index.ts
+++ b/lib/routes/buaa/news/index.ts
@@ -44,7 +44,7 @@ async function handler(ctx: Context): Promise {
return {
title: title.text(),
link: new URL(title.attr('href')!, baseUrl).href,
- pubDate: timezone(parseDate(item.find('h2 em').text(), '[YYYY-MM-DD]'), +8),
+ pubDate: timezone(parseDate(item.find('h2 em').text(), '[YYYY-MM-DD]'), 8),
};
});
diff --git a/lib/routes/buaa/sme.ts b/lib/routes/buaa/sme.ts
index 2e370a20e..7869d8b61 100755
--- a/lib/routes/buaa/sme.ts
+++ b/lib/routes/buaa/sme.ts
@@ -79,7 +79,7 @@ async function getList(url) {
return {
title: item.find('a').text(),
link: link?.startsWith('http') ? link : `${BASE_URL}/${link}`, // 有些链接是相对路径
- pubDate: timezone(parseDate(item.find('span').text()), +8),
+ pubDate: timezone(parseDate(item.find('span').text()), 8),
};
});
return {
diff --git a/lib/routes/bupt/jwc.ts b/lib/routes/bupt/jwc.ts
index 9439c979e..4051dff75 100644
--- a/lib/routes/bupt/jwc.ts
+++ b/lib/routes/bupt/jwc.ts
@@ -116,7 +116,7 @@ async function handler(ctx: Context) {
// 提取并格式化发布时间
item.description = cleanedDescription;
- item.pubDate = timezone(parseDate(content('.info').text().replace('发布时间:', '').trim()), +8);
+ item.pubDate = timezone(parseDate(content('.info').text().replace('发布时间:', '').trim()), 8);
return item;
})
diff --git a/lib/routes/bupt/rczp.ts b/lib/routes/bupt/rczp.ts
index acf1d795c..b3bda326c 100644
--- a/lib/routes/bupt/rczp.ts
+++ b/lib/routes/bupt/rczp.ts
@@ -63,7 +63,7 @@ async function handler() {
const content = load(detailResponse.data);
item.description = content('.v_news_content').html();
- item.pubDate = timezone(parseDate(content('.info span').first().text().replace('发布时间 : ', '')), +8);
+ item.pubDate = timezone(parseDate(content('.info span').first().text().replace('发布时间 : ', '')), 8);
return item;
})
diff --git a/lib/routes/bupt/scss.ts b/lib/routes/bupt/scss.ts
index 7db560446..28113c9b1 100644
--- a/lib/routes/bupt/scss.ts
+++ b/lib/routes/bupt/scss.ts
@@ -84,7 +84,7 @@ async function handler() {
});
item.description = newsContent.text();
- item.pubDate = timezone(parseDate(item.pubDateRaw), +8);
+ item.pubDate = timezone(parseDate(item.pubDateRaw), 8);
return item;
})
diff --git a/lib/routes/byau/xinwen/index.ts b/lib/routes/byau/xinwen/index.ts
index 33a051dd5..e2208648c 100644
--- a/lib/routes/byau/xinwen/index.ts
+++ b/lib/routes/byau/xinwen/index.ts
@@ -48,7 +48,7 @@ async function handler(ctx) {
return {
title: $$('a').text(),
link: itemUrl,
- pubDate: timezone(parseDate($$('.news_meta').text()), +8),
+ pubDate: timezone(parseDate($$('.news_meta').text()), 8),
};
});
diff --git a/lib/routes/c114/roll.ts b/lib/routes/c114/roll.ts
index 9ed0d5187..322f59ed7 100644
--- a/lib/routes/c114/roll.ts
+++ b/lib/routes/c114/roll.ts
@@ -30,7 +30,7 @@ export const handler = async (ctx) => {
return {
title: item.find('h6 a').text(),
- pubDate: timezone(parseDate(item.find('div.new_list_time').text(), ['HH:mm', 'M/D']), +8),
+ pubDate: timezone(parseDate(item.find('div.new_list_time').text(), ['HH:mm', 'M/D']), 8),
link: new URL(item.find('h6 a').prop('href'), rootUrl).href,
author: item.find('div.new_list_author').text().trim(),
language,
@@ -51,7 +51,7 @@ export const handler = async (ctx) => {
item.title = title;
item.description = description;
- item.pubDate = timezone(parseDate($$('div.r_time').text(), 'YYYY/M/D HH:mm'), +8);
+ item.pubDate = timezone(parseDate($$('div.r_time').text(), 'YYYY/M/D HH:mm'), 8);
item.author = $$('div.author').first().text().trim();
item.content = {
html: description,
diff --git a/lib/routes/caai/utils.tsx b/lib/routes/caai/utils.tsx
index dbbee5e7a..ea339e7c6 100644
--- a/lib/routes/caai/utils.tsx
+++ b/lib/routes/caai/utils.tsx
@@ -28,7 +28,7 @@ const fetchAllArticles = (data) => {
const r = {
title: c.find('h3 a[href]').text().trim(),
link: base + c.find('h3 a[href]').attr('href'),
- pubDate: timezone(parseDate(c.find('h4').text().trim(), 'YYYY-MM-DD'), +8),
+ pubDate: timezone(parseDate(c.find('h4').text().trim(), 'YYYY-MM-DD'), 8),
};
return r;
});
diff --git a/lib/routes/cahkms/index.tsx b/lib/routes/cahkms/index.tsx
index 62d9585ad..a28296253 100644
--- a/lib/routes/cahkms/index.tsx
+++ b/lib/routes/cahkms/index.tsx
@@ -68,7 +68,7 @@ async function handler(ctx) {
.map((item) => ({
title: item.TITLE,
description: `${item.GJZ}
`,
- pubDate: timezone(parseDate(item.JDRQ), +8),
+ pubDate: timezone(parseDate(item.JDRQ), 8),
link: `${rootUrl}/HKMAC/indexMac/getWzxx?id=${item.ID}`,
}));
diff --git a/lib/routes/caijing/roll.ts b/lib/routes/caijing/roll.ts
index eac82084e..fa8bd8d0f 100644
--- a/lib/routes/caijing/roll.ts
+++ b/lib/routes/caijing/roll.ts
@@ -42,7 +42,7 @@ async function handler() {
const list = response.data.map((item) => ({
title: item.title,
link: item.url.replace('http://', 'https://'),
- pubDate: timezone(parseDate(item.published, 'MM-DD HH:mm'), +8),
+ pubDate: timezone(parseDate(item.published, 'MM-DD HH:mm'), 8),
category: item.cat,
}));
diff --git a/lib/routes/caixin/category.ts b/lib/routes/caixin/category.ts
index 9e4e7dc83..081c7b557 100644
--- a/lib/routes/caixin/category.ts
+++ b/lib/routes/caixin/category.ts
@@ -79,7 +79,7 @@ async function handler(ctx) {
title: item.desc,
description: item.summ,
link: item.link.replace('http://', 'https://'),
- pubDate: timezone(parseDate(item.time), +8),
+ pubDate: timezone(parseDate(item.time), 8),
category: item.keyword.split(' '),
audio: item.audioUrl,
audio_image_url: item.pict.imgs[0].url,
diff --git a/lib/routes/caixin/database.ts b/lib/routes/caixin/database.ts
index 2c2180013..63eebef05 100644
--- a/lib/routes/caixin/database.ts
+++ b/lib/routes/caixin/database.ts
@@ -55,7 +55,7 @@ async function handler() {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
- item.pubDate = timezone(parseDate(content('#pubtime_baidu').text()), +8);
+ item.pubDate = timezone(parseDate(content('#pubtime_baidu').text()), 8);
item.description = renderArticle({
item,
$: content,
diff --git a/lib/routes/cankaoxiaoxi/index.tsx b/lib/routes/cankaoxiaoxi/index.tsx
index 9eb373540..a2069e218 100644
--- a/lib/routes/cankaoxiaoxi/index.tsx
+++ b/lib/routes/cankaoxiaoxi/index.tsx
@@ -68,7 +68,7 @@ async function handler(ctx) {
title: item.data.title,
author: item.data.userName,
category: item.data.channelName,
- pubDate: timezone(parseDate(item.data.publishTime), +8),
+ pubDate: timezone(parseDate(item.data.publishTime), 8),
link: item.data.moVideoPath ? item.data.sourceUrl : `${rootUrl}/json/content/${item.data.url.match(/\/pages\/(.*?)\.html/)[1]}.detailjson`,
video: item.data.moVideoPath,
cover: item.data.mCoverImg,
diff --git a/lib/routes/cast/index.ts b/lib/routes/cast/index.ts
index dd8e0f34f..32732e8e1 100644
--- a/lib/routes/cast/index.ts
+++ b/lib/routes/cast/index.ts
@@ -27,7 +27,7 @@ async function parsePage(html: string) {
return cache.tryGet(articleUrl, async () => {
const res = await got.get(articleUrl!);
const article = load(res.data);
- const pubDate = timezone(parseDate(article('meta[name=PubDate]').attr('content')!, 'YYYY-MM-DD HH:mm'), +8);
+ const pubDate = timezone(parseDate(article('meta[name=PubDate]').attr('content')!, 'YYYY-MM-DD HH:mm'), 8);
return {
title: title.text(),
diff --git a/lib/routes/cbpanet/index.ts b/lib/routes/cbpanet/index.ts
index 89c858084..1694fee9c 100644
--- a/lib/routes/cbpanet/index.ts
+++ b/lib/routes/cbpanet/index.ts
@@ -52,7 +52,7 @@ export const handler = async (ctx) => {
.replace(/发布时间:/, ''),
'YYYY/M/D HH:mm:ss'
),
- +8
+ 8
);
item.content = {
html: description,
diff --git a/lib/routes/ccagm/index.ts b/lib/routes/ccagm/index.ts
index 9f56e8f18..86fdb8ae1 100644
--- a/lib/routes/ccagm/index.ts
+++ b/lib/routes/ccagm/index.ts
@@ -34,9 +34,9 @@ export const handler = async (ctx: Context): Promise => {
const processedItem: DataItem = {
title,
- pubDate: pubDateStr ? timezone(parseDate(pubDateStr), +8) : undefined,
+ pubDate: pubDateStr ? timezone(parseDate(pubDateStr), 8) : undefined,
link: linkUrl,
- updated: upDatedStr ? timezone(parseDate(upDatedStr), +8) : undefined,
+ updated: upDatedStr ? timezone(parseDate(upDatedStr), 8) : undefined,
language,
};
@@ -61,12 +61,12 @@ export const handler = async (ctx: Context): Promise => {
const processedItem: DataItem = {
title,
description,
- pubDate: pubDateStr ? timezone(parseDate(pubDateStr), +8) : item.pubDate,
+ pubDate: pubDateStr ? timezone(parseDate(pubDateStr), 8) : item.pubDate,
content: {
html: description,
text: description,
},
- updated: upDatedStr ? timezone(parseDate(upDatedStr), +8) : item.updated,
+ updated: upDatedStr ? timezone(parseDate(upDatedStr), 8) : item.updated,
language,
};
diff --git a/lib/routes/cccfna/index.ts b/lib/routes/cccfna/index.ts
index 0ff78618e..dade94534 100644
--- a/lib/routes/cccfna/index.ts
+++ b/lib/routes/cccfna/index.ts
@@ -66,7 +66,7 @@ export const route: Route = {
const content = $('.list_cont');
item.title = content.find('.title').text();
- item.pubDate = timezone(parseDate(content.find('.tip > .time').text(), '发布时间:YYYY-MM-DD'), +8);
+ item.pubDate = timezone(parseDate(content.find('.tip > .time').text(), '发布时间:YYYY-MM-DD'), 8);
item.description = content.find('#article-content').html()!;
return item;
diff --git a/lib/routes/ccf/tfbd/utils.tsx b/lib/routes/ccf/tfbd/utils.tsx
index bebaced5a..69666d278 100644
--- a/lib/routes/ccf/tfbd/utils.tsx
+++ b/lib/routes/ccf/tfbd/utils.tsx
@@ -29,7 +29,7 @@ const fetchAllArticles = (data) => {
const r = {
title: c.find('h3 a[href]').text().trim(),
link: base + c.find('h3 a[href]').attr('href'),
- pubDate: timezone(parseDate(c.find('p').text().trim(), 'YYYY-MM-DD'), +8),
+ pubDate: timezone(parseDate(c.find('p').text().trim(), 'YYYY-MM-DD'), 8),
};
return r;
});
diff --git a/lib/routes/ccmn/price-adjustment.tsx b/lib/routes/ccmn/price-adjustment.tsx
index 09c2bc822..cf11a670e 100644
--- a/lib/routes/ccmn/price-adjustment.tsx
+++ b/lib/routes/ccmn/price-adjustment.tsx
@@ -191,7 +191,7 @@ async function handler(ctx) {
description,
link: `${url}/quota/${dataId}.html`,
guid: dataId, // 使用 data-id 作为唯一标识
- pubDate: timezone(parseDate(dateStr, 'MM-DD'), +8),
+ pubDate: timezone(parseDate(dateStr, 'MM-DD'), 8),
};
});
diff --git a/lib/routes/ccreports/index.ts b/lib/routes/ccreports/index.ts
index 969e3e137..34ea40c58 100644
--- a/lib/routes/ccreports/index.ts
+++ b/lib/routes/ccreports/index.ts
@@ -53,7 +53,7 @@ async function handler() {
const detailData = await got.get(item.link);
const $ = load(detailData.data);
item.description = $('div.pdbox').html();
- item.pubDate = timezone(parseDate($('div.newbox > div.newtit > p').text(), 'YYYY-MM-DD HH:mm:ss'), +8);
+ item.pubDate = timezone(parseDate($('div.newbox > div.newtit > p').text(), 'YYYY-MM-DD HH:mm:ss'), 8);
return item;
})
diff --git a/lib/routes/cctv/category.ts b/lib/routes/cctv/category.ts
index 6b018770a..90026d7aa 100644
--- a/lib/routes/cctv/category.ts
+++ b/lib/routes/cctv/category.ts
@@ -1,8 +1,8 @@
import type { Route } from '@/types';
-import getMzzlbg from './utils/mzzlbg';
-import getNews from './utils/news';
-import xinwen1j1 from './utils/xinwen1j1';
+import { getMzzlbg } from './utils/mzzlbg';
+import { getNews } from './utils/news';
+import { xinwen1j1 } from './utils/xinwen1j1';
import getXWLB from './xwlb';
export const route: Route = {
diff --git a/lib/routes/cctv/lm.ts b/lib/routes/cctv/lm.ts
index e378927a1..556fe12b6 100644
--- a/lib/routes/cctv/lm.ts
+++ b/lib/routes/cctv/lm.ts
@@ -70,7 +70,7 @@ async function handler(ctx) {
guid: item.guid,
image: item.image,
title: item.title,
- pubDate: timezone(parseDate(item.time), +8),
+ pubDate: timezone(parseDate(item.time), 8),
link: `${vdnRootUrl}/api/getHttpVideoInfo.do?pid=${item.guid}`,
description: `${item.brief.replaceAll('\r\n', '
')}
`,
}));
diff --git a/lib/routes/cctv/utils/mzzlbg.ts b/lib/routes/cctv/utils/mzzlbg.ts
index 74a373b92..7cd0154ff 100644
--- a/lib/routes/cctv/utils/mzzlbg.ts
+++ b/lib/routes/cctv/utils/mzzlbg.ts
@@ -2,7 +2,7 @@ import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
-const getMzzlbg = async () => {
+export const getMzzlbg = async () => {
const url = 'https://api.cntv.cn/video/videolistById?serviceId=cbox&vsid=C10354&em=01&p=1&n=50';
const response = await got({
@@ -19,7 +19,7 @@ const getMzzlbg = async () => {
title: video.t,
description: video.desc,
link: video.url,
- pubDate: timezone(parseDate(video.ptime), +8),
+ pubDate: timezone(parseDate(video.ptime), 8),
};
const { data: videoDetail } = await got({
method: 'get',
@@ -39,4 +39,3 @@ const getMzzlbg = async () => {
item: resultItem,
};
};
-export default getMzzlbg;
diff --git a/lib/routes/cctv/utils/news.ts b/lib/routes/cctv/utils/news.ts
index 8c1c87acf..5c5e6455c 100644
--- a/lib/routes/cctv/utils/news.ts
+++ b/lib/routes/cctv/utils/news.ts
@@ -6,7 +6,7 @@ import { PRESETS } from '@/utils/header-generator';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
-const getNews = async (category) => {
+export const getNews = async (category) => {
const url = `https://news.cctv.com/2019/07/gaiban/cmsdatainterface/page/${category}_1.jsonp`;
const response = await got({
@@ -26,7 +26,7 @@ const getNews = async (category) => {
const item = {
title,
link: url,
- pubDate: timezone(parseDate(focus_date), +8),
+ pubDate: timezone(parseDate(focus_date), 8),
};
const id = path.parse(url).name;
const unknownTip = '未知类型,请点击链接提交issue';
@@ -103,4 +103,3 @@ const getNews = async (category) => {
item: resultItem,
};
};
-export default getNews;
diff --git a/lib/routes/cctv/utils/xinwen1j1.ts b/lib/routes/cctv/utils/xinwen1j1.ts
index 7122269a8..aaebe3174 100644
--- a/lib/routes/cctv/utils/xinwen1j1.ts
+++ b/lib/routes/cctv/utils/xinwen1j1.ts
@@ -54,7 +54,7 @@ const ProcessFeed = (data) =>
return { ...single, ...other };
})
);
-const xinwen1j1 = async () => {
+export const xinwen1j1 = async () => {
const baseUrl = 'https://api.cntv.cn/NewVideo/getVideoListByColumn?id=TOPC1451559066181661&n=20&sort=desc&p=1&mode=0&serviceId=tvcctv';
// 获取要处理的页面
const res = await got({
@@ -81,4 +81,3 @@ const xinwen1j1 = async () => {
item: result,
};
};
-export default xinwen1j1;
diff --git a/lib/routes/cctv/xwlb.ts b/lib/routes/cctv/xwlb.ts
index 3c2bf56b5..b6dd266a4 100644
--- a/lib/routes/cctv/xwlb.ts
+++ b/lib/routes/cctv/xwlb.ts
@@ -72,7 +72,7 @@ const getXWLB = async () => {
const item = {
title: `新闻联播 ${newsDate.format('YYYY/MM/DD')}`,
link: url,
- pubDate: timezone(parseDate(newsDate.format()), +8),
+ pubDate: timezone(parseDate(newsDate.format()), 8),
description: await cache.tryGet(url, async () => {
const res = await got(url);
const content = load(res.data);
diff --git a/lib/routes/cdi/index.ts b/lib/routes/cdi/index.ts
index f518124bf..65331910e 100644
--- a/lib/routes/cdi/index.ts
+++ b/lib/routes/cdi/index.ts
@@ -69,7 +69,7 @@ async function handler(ctx) {
.match(/时间:(.*)/)[1]
.replaceAll(/年|月/g, '-')
),
- +8
+ 8
);
return item;
diff --git a/lib/routes/ce/district.ts b/lib/routes/ce/district.ts
index 220715b56..1621eb581 100644
--- a/lib/routes/ce/district.ts
+++ b/lib/routes/ce/district.ts
@@ -77,7 +77,7 @@ async function handler(ctx) {
const $ = load(response);
const pubDateText = $('span#articleTime').text().trim();
- item.pubDate = timezone(parseDate(pubDateText, 'YYYY年MM月DD日 HH:mm'), +8);
+ item.pubDate = timezone(parseDate(pubDateText, 'YYYY年MM月DD日 HH:mm'), 8);
item.description = $('div.TRS_Editor').html();
return item;
diff --git a/lib/routes/cfachina/analygarden.ts b/lib/routes/cfachina/analygarden.ts
index 07f640b2c..78d20a34a 100644
--- a/lib/routes/cfachina/analygarden.ts
+++ b/lib/routes/cfachina/analygarden.ts
@@ -38,7 +38,7 @@ async function handler(ctx) {
pageUrl = `${baseUrl}/servicesupport/analygarden/`;
if (program !== '分析师园地') {
- pageUrl = `${pageUrl}${program}/`;
+ pageUrl += `${program}/`;
const response = await got(pageUrl);
const $ = load(response.data);
@@ -74,7 +74,7 @@ async function handler(ctx) {
title: item.docTitle,
author: item.docAuthor,
link,
- pubDate: timezone(parseDate(item.operTime), +8),
+ pubDate: timezone(parseDate(item.operTime), 8),
enclosure_url: link,
enclosure_type: `application/${link.split('.').pop()}`,
};
diff --git a/lib/routes/cffex/announcement.ts b/lib/routes/cffex/announcement.ts
index ecbac0127..7a85667da 100644
--- a/lib/routes/cffex/announcement.ts
+++ b/lib/routes/cffex/announcement.ts
@@ -49,7 +49,7 @@ async function handler(): Promise<{ title: string; link: string; item: DataItem[
return {
title: titleEle.text().trim(),
link: `${baseUrl}${titleEle.attr('href')}`,
- pubDate: timezone(parseDate(dateEle.text(), 'YYYY-MM-DD'), +8),
+ pubDate: timezone(parseDate(dateEle.text(), 'YYYY-MM-DD'), 8),
};
});
diff --git a/lib/routes/cfmmc/index.ts b/lib/routes/cfmmc/index.ts
index e1c5105c1..faa2a6a24 100644
--- a/lib/routes/cfmmc/index.ts
+++ b/lib/routes/cfmmc/index.ts
@@ -47,7 +47,7 @@ async function handler(ctx) {
response.results?.[0].data.slice(0, limit).map((item) => ({
title: item.title,
link: new URL(item.url, rootUrl).href,
- pubDate: timezone(parseDate(item.publish_date), +8),
+ pubDate: timezone(parseDate(item.publish_date), 8),
})) ?? [];
items = await Promise.all(
diff --git a/lib/routes/cgtn/podcast.ts b/lib/routes/cgtn/podcast.ts
index 4a5c773f5..e32de8506 100644
--- a/lib/routes/cgtn/podcast.ts
+++ b/lib/routes/cgtn/podcast.ts
@@ -11,7 +11,7 @@ async function getData(category, id) {
function combDate(date, time) {
// combine date and time, return a Date object
- return timezone(parseDate(date + ' ' + time), +8);
+ return timezone(parseDate(date + ' ' + time), 8);
}
export const route: Route = {
diff --git a/lib/routes/chiculture/topic.ts b/lib/routes/chiculture/topic.ts
index 8edf833f4..7c9f95ab3 100644
--- a/lib/routes/chiculture/topic.ts
+++ b/lib/routes/chiculture/topic.ts
@@ -58,11 +58,13 @@ async function handler(ctx) {
item.pubDate = parseDate(pubDate[1]);
} else if (item.title.includes('一周時事通識')) {
for (const tag of item.pubDate) {
- if (/^\d{4}年$/.test(tag.title)) {
- const monthDayStr = item.title.split('- ', 2)[1] ?? item.title.split('-', 2)[1];
- item.pubDate = timezone(parseDate(monthDayStr, 'D/M'), +8);
- break;
+ if (!/^\d{4}年$/.test(tag.title)) {
+ continue;
}
+
+ const monthDayStr = item.title.split('- ', 2)[1] ?? item.title.split('-', 2)[1];
+ item.pubDate = timezone(parseDate(monthDayStr, 'D/M'), 8);
+ break;
}
} else if (/^\d{4}年新聞回顧$/.test(item.title)) {
item.pubDate = parseDate(`${item.title.split('年', 1)[0]}-12-31`);
diff --git a/lib/routes/china/finance/finance.ts b/lib/routes/china/finance/finance.ts
index ac174799e..f4d69fc88 100644
--- a/lib/routes/china/finance/finance.ts
+++ b/lib/routes/china/finance/finance.ts
@@ -77,7 +77,7 @@ async function handler(ctx) {
title: $d('.article_title').text(),
link: item.link,
description: $d('#js_article_content').html(),
- pubDate: timezone(parseDate($d('.article_info>span.time').text()), +8),
+ pubDate: timezone(parseDate($d('.article_info>span.time').text()), 8),
author: $d(' div.article_info > span.source').text(),
category: listCategory,
};
diff --git a/lib/routes/chinadaily/language.ts b/lib/routes/chinadaily/language.ts
index 21189db52..dae3316c8 100644
--- a/lib/routes/chinadaily/language.ts
+++ b/lib/routes/chinadaily/language.ts
@@ -96,12 +96,12 @@ export const handler = async (ctx: Context): Promise => {
let processedItem: DataItem = {
title,
- pubDate: pubDateStr ? timezone(parseDate(pubDateStr), +8) : item.pubDate,
+ pubDate: pubDateStr ? timezone(parseDate(pubDateStr), 8) : item.pubDate,
category: categories,
author: authors,
image,
banner: image,
- updated: upDatedStr ? timezone(parseDate(upDatedStr), +8) : item.updated,
+ updated: upDatedStr ? timezone(parseDate(upDatedStr), 8) : item.updated,
language,
};
diff --git a/lib/routes/chinamoney/notice.ts b/lib/routes/chinamoney/notice.ts
index 686f1910a..cf58a1e5f 100644
--- a/lib/routes/chinamoney/notice.ts
+++ b/lib/routes/chinamoney/notice.ts
@@ -74,7 +74,7 @@ async function handler(ctx) {
const list = contents.records.map((item) => ({
title: item.title,
link: `${baseUrl}${item.draftPath}`,
- pubDate: timezone(parseDate(item.releaseDate, 'YYYY-MM-DD'), +8),
+ pubDate: timezone(parseDate(item.releaseDate, 'YYYY-MM-DD'), 8),
contentId: item.contentId,
}));
@@ -101,7 +101,7 @@ async function handler(ctx) {
});
item.description = article.html();
- item.pubDate = timezone(parseDate($('.AC-l span').text().trim(), 'YYYY-MM-DD HH:mm'), +8);
+ item.pubDate = timezone(parseDate($('.AC-l span').text().trim(), 'YYYY-MM-DD HH:mm'), 8);
return item;
})
diff --git a/lib/routes/chinanews/index.ts b/lib/routes/chinanews/index.ts
index 2cc0f9195..883131a78 100644
--- a/lib/routes/chinanews/index.ts
+++ b/lib/routes/chinanews/index.ts
@@ -52,12 +52,12 @@ async function handler(ctx) {
item.author = content('a.source').text();
const info = content('p', '.left').text().trim().slice(5).split(' ');
item.author = info[2].trim();
- item.pubDate = timezone(parseDate(info[0] + info[1], 'YYYY年MM月DD日HH:mm'), +8);
+ item.pubDate = timezone(parseDate(info[0] + info[1], 'YYYY年MM月DD日HH:mm'), 8);
} else if (content('div.t3').length > 0) {
item.description = content('div.t3').html();
const info = content('div[style="text-align:right;font-size:12px;"]').text().slice(5).split(' ');
item.author = info[2];
- item.pubDate = timezone(parseDate(info[0] + info[1], 'YYYY-MM-DDHH:mm'), +8);
+ item.pubDate = timezone(parseDate(info[0] + info[1], 'YYYY-MM-DDHH:mm'), 8);
} else {
item.description = content('div.left_zw').html();
const info = content('div.left-t')
@@ -65,7 +65,7 @@ async function handler(ctx) {
.filter((_, el) => el.type === 'text')
.text()
.split(' ');
- item.pubDate = timezone(parseDate(info[0], 'YYYY年MM月DD日 HH:mm'), +8);
+ item.pubDate = timezone(parseDate(info[0], 'YYYY年MM月DD日 HH:mm'), 8);
item.author = info[1] + content('a.source').text();
}
return item;
diff --git a/lib/routes/chinathinktanks/viewpoint.ts b/lib/routes/chinathinktanks/viewpoint.ts
index 98115a0fe..48d069e20 100644
--- a/lib/routes/chinathinktanks/viewpoint.ts
+++ b/lib/routes/chinathinktanks/viewpoint.ts
@@ -105,7 +105,7 @@ async function handler(ctx) {
const $ = load(response.data);
const content = $('#art');
item.description = content.html();
- item.pubDate = item.pubDate.includes('-') ? timezone(parseDate(item.pubDate, 'YYYY-MM-DD'), +8) : parseRelativeDate(item.pubDate);
+ item.pubDate = item.pubDate.includes('-') ? timezone(parseDate(item.pubDate, 'YYYY-MM-DD'), 8) : parseRelativeDate(item.pubDate);
return item;
})
diff --git a/lib/routes/chinaventure/index.ts b/lib/routes/chinaventure/index.ts
index af8064d73..88e84c418 100644
--- a/lib/routes/chinaventure/index.ts
+++ b/lib/routes/chinaventure/index.ts
@@ -77,7 +77,7 @@ async function handler(ctx) {
item.title = content('h1.maintitle_pc').text();
item.description = content('div.article_slice_pc').html();
item.author = content('div.source_author').text();
- item.pubDate = timezone(parseDate(content('div.releaseTime').text()), +8);
+ item.pubDate = timezone(parseDate(content('div.releaseTime').text()), 8);
return item;
})
)
diff --git a/lib/routes/chinawriter/index.ts b/lib/routes/chinawriter/index.ts
index 89a6da096..87c61b8ec 100644
--- a/lib/routes/chinawriter/index.ts
+++ b/lib/routes/chinawriter/index.ts
@@ -71,7 +71,7 @@ async function handler(ctx) {
].filter(Boolean)
),
];
- item.pubDate = content('div.end_info em').text() ? timezone(parseDate(content('div.end_info em').text(), 'YYYY年MM月DD日HH:mm'), +8) : parseDate(content('meta[name="publishdate"]').prop('content'));
+ item.pubDate = content('div.end_info em').text() ? timezone(parseDate(content('div.end_info em').text(), 'YYYY年MM月DD日HH:mm'), 8) : parseDate(content('meta[name="publishdate"]').prop('content'));
} catch {
//
}
diff --git a/lib/routes/chiphell/portal.ts b/lib/routes/chiphell/portal.ts
index 1ff83542b..752de923a 100644
--- a/lib/routes/chiphell/portal.ts
+++ b/lib/routes/chiphell/portal.ts
@@ -24,7 +24,7 @@ const handler = async (ctx: Context) => {
title: a.text(),
link: `https://www.chiphell.com/${a.attr('href')}`,
category: [$item.find('dd label').text()],
- pubDate: timezone(parseDate($item.find('span.xg1').text()), +8),
+ pubDate: timezone(parseDate($item.find('span.xg1').text()), 8),
};
});
diff --git a/lib/routes/chlinlearn/daily-blog.ts b/lib/routes/chlinlearn/daily-blog.ts
index e0ef1a3aa..a5a35e111 100644
--- a/lib/routes/chlinlearn/daily-blog.ts
+++ b/lib/routes/chlinlearn/daily-blog.ts
@@ -42,7 +42,7 @@ export const route: Route = {
link: item.url,
author: item.author,
img: item.icon,
- pubDate: timezone(parseDate(item.publishTime), +8),
+ pubDate: timezone(parseDate(item.publishTime), 8),
}));
return {
// 源标题
diff --git a/lib/routes/chnmuseum/xingnew.ts b/lib/routes/chnmuseum/xingnew.ts
index cc234a046..85716e004 100644
--- a/lib/routes/chnmuseum/xingnew.ts
+++ b/lib/routes/chnmuseum/xingnew.ts
@@ -41,7 +41,7 @@ export const route: Route = {
return {
title: a.attr('title') || a.text(),
link: new URL(a.attr('href'), 'https://www.chnmuseum.cn/zx/xingnew/').href,
- pubDate: timezone(parseDate(dateText, 'YYYY/MM/DD'), +8),
+ pubDate: timezone(parseDate(dateText, 'YYYY/MM/DD'), 8),
// description: a.attr('title') || a.text(),
};
});
diff --git a/lib/routes/chnmuseum/zl.tsx b/lib/routes/chnmuseum/zl.tsx
index 71c0b0d32..65e832285 100644
--- a/lib/routes/chnmuseum/zl.tsx
+++ b/lib/routes/chnmuseum/zl.tsx
@@ -34,8 +34,7 @@ const formatExhibitionDate = (dateStr: string | undefined): string | undefined =
const normalized = dateStr
.replaceAll(/年|月/g, '-')
.replaceAll('日', '')
- .replaceAll('/', '-')
- .replaceAll('.', '-');
+ .replaceAll(/[/.]/g, '-');
const parts = normalized.split('-').filter(Boolean);
if (parts.length === 3) {
return `${parts[0]}-${parts[1].padStart(2, '0')}-${parts[2].padStart(2, '0')}`;
diff --git a/lib/routes/cih-index/report.ts b/lib/routes/cih-index/report.ts
index a61197bdb..b1008c181 100644
--- a/lib/routes/cih-index/report.ts
+++ b/lib/routes/cih-index/report.ts
@@ -53,7 +53,7 @@ async function handler(ctx) {
return {
title: info.reportTitle,
link: `${baseUrl}/report/detail/${info.reportId}.html`,
- pubDate: timezone(parseDate(info.addTime), +8),
+ pubDate: timezone(parseDate(info.addTime), 8),
category: [...new Set([...info.reportClassTagDtoList.map((t) => t.tag), ...(info.keywordList || [])])],
description: `${info.context}
${images}`,
image: `${info.coverFigureUrl}/200`,
diff --git a/lib/routes/ciidbnu/index.ts b/lib/routes/ciidbnu/index.ts
index f9411e84a..92605a984 100644
--- a/lib/routes/ciidbnu/index.ts
+++ b/lib/routes/ciidbnu/index.ts
@@ -62,7 +62,7 @@ async function handler(ctx) {
const content = load(iconv.decode(detailResponse.data, 'gbk'));
item.description = content('#text').html();
- item.pubDate = timezone(parseDate(content('.t8').eq(0).text(), 'YYYY/M/D H:mm:ss'), +8);
+ item.pubDate = timezone(parseDate(content('.t8').eq(0).text(), 'YYYY/M/D H:mm:ss'), 8);
content('.t14').remove();
diff --git a/lib/routes/ciweimao/chapter.ts b/lib/routes/ciweimao/chapter.ts
index 10412edba..0faa2d8ce 100644
--- a/lib/routes/ciweimao/chapter.ts
+++ b/lib/routes/ciweimao/chapter.ts
@@ -53,7 +53,7 @@ async function handler(ctx) {
return {
chapterLocked: item.find('h3 i.icon-lock').length > 0,
title: item.find('h3').text(),
- pubDate: timezone(parseDate(item.find('p').text().replace('发布于 ', '')), +8),
+ pubDate: timezone(parseDate(item.find('p').text().replace('发布于 ', '')), 8),
link: item.attr('href'),
};
});
diff --git a/lib/routes/cjlu/yjsy/index.ts b/lib/routes/cjlu/yjsy/index.ts
index b91cd90ff..1d06a3d55 100644
--- a/lib/routes/cjlu/yjsy/index.ts
+++ b/lib/routes/cjlu/yjsy/index.ts
@@ -120,7 +120,7 @@ async function handler(ctx) {
return {
title: a.attr('title') ?? titleMap.get(cate) ?? '中量大研究生院通知',
- pubDate: timezone(parseDate(timeStr, 'YYYY/MM/DD'), +8),
+ pubDate: timezone(parseDate(timeStr, 'YYYY/MM/DD'), 8),
link: `${host}${route}`,
description: '',
};
diff --git a/lib/routes/cloudnative/blog.ts b/lib/routes/cloudnative/blog.ts
index 4da530cc9..c286a0445 100644
--- a/lib/routes/cloudnative/blog.ts
+++ b/lib/routes/cloudnative/blog.ts
@@ -19,7 +19,7 @@ async function getArticles() {
title: a.text(),
link: a.attr('href'),
description: summary.text(),
- pubDate: timezone(parseDate(time, 'YYYY-MM-DD'), +8),
+ pubDate: timezone(parseDate(time, 'YYYY-MM-DD'), 8),
author: meta.find('span').eq(0).find('a').text(),
category: meta.find('.article-categories a').text(),
};
diff --git a/lib/routes/cma/channel.tsx b/lib/routes/cma/channel.tsx
index 7eb1fd967..abdcf0c96 100644
--- a/lib/routes/cma/channel.tsx
+++ b/lib/routes/cma/channel.tsx
@@ -110,7 +110,7 @@ async function handler(ctx) {
?.split(/:/)
?.pop() || author,
guid: `cma${data.link}#${data.releaseTime.replaceAll(/\s/g, '-')}`,
- pubDate: timezone(parseDate(data.releaseTime), +8),
+ pubDate: timezone(parseDate(data.releaseTime), 8),
enclosure_url: new URL(data.image, rootUrl).href,
enclosure_type: data.image ? `image/${data.image.split(/\./).pop()}` : undefined,
},
diff --git a/lib/routes/cmde/index.ts b/lib/routes/cmde/index.ts
index 6e3d8c1cf..910b5b16b 100644
--- a/lib/routes/cmde/index.ts
+++ b/lib/routes/cmde/index.ts
@@ -66,7 +66,7 @@ async function handler(ctx) {
await page.close();
const $ = load(html);
item.description = $('.text').html();
- item.pubDate = timezone(parseDate($('meta[name="PubDate"]').attr('content')), +8);
+ item.pubDate = timezone(parseDate($('meta[name="PubDate"]').attr('content')), 8);
return item;
})
)
diff --git a/lib/routes/cna/index.ts b/lib/routes/cna/index.ts
index 77006e483..4b27805ae 100644
--- a/lib/routes/cna/index.ts
+++ b/lib/routes/cna/index.ts
@@ -52,7 +52,7 @@ async function handler(ctx) {
const list = (isTopic ? resultData.Topic.NewsItems : resultData.Items).slice(0, limit).map((item) => ({
title: item.HeadLine,
link: item.PageUrl,
- pubDate: timezone(parseDate(item.CreateTime), +8),
+ pubDate: timezone(parseDate(item.CreateTime), 8),
}));
const items = await Promise.all(list.map((item) => cache.tryGet(item.link, async () => await getFullText(item))));
diff --git a/lib/routes/cna/web/index.ts b/lib/routes/cna/web/index.ts
index b56bd7921..3c29a6fae 100644
--- a/lib/routes/cna/web/index.ts
+++ b/lib/routes/cna/web/index.ts
@@ -44,7 +44,7 @@ async function handler(ctx) {
return {
title: item.text(),
link: new URL(item.parents('a').attr('href'), 'https://www.cna.com.tw').href,
- pubDate: timezone(parseDate(item.next().text()), +8),
+ pubDate: timezone(parseDate(item.next().text()), 8),
};
});
diff --git a/lib/routes/cnbeta/common.ts b/lib/routes/cnbeta/common.ts
index 60f2e6123..08a261ace 100644
--- a/lib/routes/cnbeta/common.ts
+++ b/lib/routes/cnbeta/common.ts
@@ -26,7 +26,7 @@ export async function handler(ctx) {
title: item.title,
description: item.hometext,
author: item.source.split('@http', 1)[0],
- pubDate: timezone(parseDate(item.inputtime), +8),
+ pubDate: timezone(parseDate(item.inputtime), 8),
link: item.url_show.startsWith('//') ? `https:${item.url_show}` : item.url_show.replace('http:', 'https:'),
category: item.label.name,
}))
diff --git a/lib/routes/cnbeta/utils.ts b/lib/routes/cnbeta/utils.ts
index a7df94b7d..96f78a1f4 100644
--- a/lib/routes/cnbeta/utils.ts
+++ b/lib/routes/cnbeta/utils.ts
@@ -18,7 +18,7 @@ const ProcessItems = (items, limit, tryGet) =>
item.description = content('.article-summary').html() + content('.article-content').html();
item.author = content('header.title div.meta span.source').text();
- item.pubDate ??= timezone(parseDate(content('.meta span').first().text(), 'YYYY年MM月DD日 HH:mm'), +8);
+ item.pubDate ??= timezone(parseDate(content('.meta span').first().text(), 'YYYY年MM月DD日 HH:mm'), 8);
return item;
})
diff --git a/lib/routes/cnblogs/common.ts b/lib/routes/cnblogs/common.ts
index 3e7be2671..98c2efe61 100644
--- a/lib/routes/cnblogs/common.ts
+++ b/lib/routes/cnblogs/common.ts
@@ -44,7 +44,7 @@ async function handler(ctx) {
return {
title: item.find('.post-item-title').text(),
link: item.find('.post-item-title').attr('href'),
- pubDate: timezone(parseDate(item.find('.post-item-foot .post-meta-item span').text() || item.find('.editorpick-item-meta').text(), ['YYYY-MM-DD HH:mm', 'YYYY-MM-DD']), +8),
+ pubDate: timezone(parseDate(item.find('.post-item-foot .post-meta-item span').text() || item.find('.editorpick-item-meta').text(), ['YYYY-MM-DD HH:mm', 'YYYY-MM-DD']), 8),
description: item.find('.post-item-summary').text(),
author: item.find('.post-item-author span').text(),
};
diff --git a/lib/routes/cncf/reports.ts b/lib/routes/cncf/reports.ts
index 16785af22..52400646c 100644
--- a/lib/routes/cncf/reports.ts
+++ b/lib/routes/cncf/reports.ts
@@ -38,7 +38,7 @@ async function handler() {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
- item.parseDate = parseDate(content('p.is-style-spaced-uppercase').splice(':')[1]);
+ item.parseDate = parseDate(content('p.is-style-spaced-uppercase').text().split(':', 2)[1]);
item.description = content('article > div.has-background').html();
return item;
diff --git a/lib/routes/cneb/yjxw.ts b/lib/routes/cneb/yjxw.ts
index 3ec000203..341b48462 100644
--- a/lib/routes/cneb/yjxw.ts
+++ b/lib/routes/cneb/yjxw.ts
@@ -71,7 +71,7 @@ async function handler(ctx) {
return {
title: a.text(),
link: a.attr('href'),
- pubDate: timezone(parseDate(item.find('span').text()), +8),
+ pubDate: timezone(parseDate(item.find('span').text()), 8),
};
});
diff --git a/lib/routes/cneb/yjxx.ts b/lib/routes/cneb/yjxx.ts
index 23ea3ee59..5a56b9e57 100644
--- a/lib/routes/cneb/yjxx.ts
+++ b/lib/routes/cneb/yjxx.ts
@@ -54,7 +54,7 @@ async function handler(ctx) {
link: item.docpuburl,
author: item.chnlname,
description: item.doccontent,
- pubDate: timezone(parseDate(item.docpubtime), +8),
+ pubDate: timezone(parseDate(item.docpubtime), 8),
}));
return {
diff --git a/lib/routes/cngal/entry.tsx b/lib/routes/cngal/entry.tsx
index a9edfe536..60dca9e99 100644
--- a/lib/routes/cngal/entry.tsx
+++ b/lib/routes/cngal/entry.tsx
@@ -42,7 +42,7 @@ async function handler(ctx) {
item: data.newsOfEntry.map((item) => ({
title: item.title,
description: renderDescription(item),
- pubDate: timezone(parseDate(item.happenedTime), +8),
+ pubDate: timezone(parseDate(item.happenedTime), 8),
link: item.link,
})),
};
diff --git a/lib/routes/coomer/index.tsx b/lib/routes/coomer/index.tsx
index d591a5e53..81fc21ac9 100644
--- a/lib/routes/coomer/index.tsx
+++ b/lib/routes/coomer/index.tsx
@@ -103,7 +103,8 @@ async function handler(ctx) {
}
});
desc = (coomerFiles.length > 0 ? coomerFiles[0] : '') + $.html();
- for (const coomerFile of coomerFiles.slice(count + 1)) {
+ const remainingCoomerFiles = coomerFiles.slice(count + 1);
+ for (const coomerFile of remainingCoomerFiles) {
desc += coomerFile;
}
diff --git a/lib/routes/cosplaytele/article.ts b/lib/routes/cosplaytele/article.ts
index 2089557dc..a6d370843 100644
--- a/lib/routes/cosplaytele/article.ts
+++ b/lib/routes/cosplaytele/article.ts
@@ -3,7 +3,7 @@ import { load } from 'cheerio';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
-async function loadArticle(link) {
+export const loadArticle = async (link) => {
const resp = await got(link);
const article = load(resp.body);
@@ -17,6 +17,4 @@ async function loadArticle(link) {
pubDate,
link,
};
-}
-
-export default loadArticle;
+};
diff --git a/lib/routes/cosplaytele/category.ts b/lib/routes/cosplaytele/category.ts
index 0111e614c..e18aa7705 100644
--- a/lib/routes/cosplaytele/category.ts
+++ b/lib/routes/cosplaytele/category.ts
@@ -4,7 +4,7 @@ import type { Route } from '@/types';
import cache from '@/utils/cache';
import got from '@/utils/got';
-import loadArticle from './article';
+import { loadArticle } from './article';
import { SUB_NAME_PREFIX, SUB_URL } from './const';
export const route: Route = {
diff --git a/lib/routes/cosplaytele/latest.ts b/lib/routes/cosplaytele/latest.ts
index 50ccbb11a..38ab47d80 100644
--- a/lib/routes/cosplaytele/latest.ts
+++ b/lib/routes/cosplaytele/latest.ts
@@ -4,7 +4,7 @@ import type { Route } from '@/types';
import cache from '@/utils/cache';
import got from '@/utils/got';
-import loadArticle from './article';
+import { loadArticle } from './article';
import { SUB_NAME_PREFIX, SUB_URL } from './const';
export const route: Route = {
diff --git a/lib/routes/cosplaytele/popular.ts b/lib/routes/cosplaytele/popular.ts
index 82b9333bf..279af76ce 100644
--- a/lib/routes/cosplaytele/popular.ts
+++ b/lib/routes/cosplaytele/popular.ts
@@ -4,7 +4,7 @@ import type { Route } from '@/types';
import cache from '@/utils/cache';
import got from '@/utils/got';
-import loadArticle from './article';
+import { loadArticle } from './article';
import { SUB_NAME_PREFIX, SUB_URL } from './const';
export const route: Route = {
diff --git a/lib/routes/cosplaytele/tag.ts b/lib/routes/cosplaytele/tag.ts
index db3639c03..c77583a6c 100644
--- a/lib/routes/cosplaytele/tag.ts
+++ b/lib/routes/cosplaytele/tag.ts
@@ -4,7 +4,7 @@ import type { Route } from '@/types';
import cache from '@/utils/cache';
import got from '@/utils/got';
-import loadArticle from './article';
+import { loadArticle } from './article';
import { SUB_NAME_PREFIX, SUB_URL } from './const';
export const route: Route = {
diff --git a/lib/routes/cpcaauto/index.ts b/lib/routes/cpcaauto/index.ts
index ce17214d1..824611ddc 100644
--- a/lib/routes/cpcaauto/index.ts
+++ b/lib/routes/cpcaauto/index.ts
@@ -44,7 +44,7 @@ export const handler = async (ctx) => {
item.title = title;
item.description = description;
- item.pubDate = timezone(parseDate($$('div.view span').first().text().split(/:/).pop()), +8);
+ item.pubDate = timezone(parseDate($$('div.view span').first().text().split(/:/).pop()), 8);
item.content = {
html: description,
text: $$('div.text').text(),
diff --git a/lib/routes/cs/index.ts b/lib/routes/cs/index.ts
index 22eba286b..85b4e998d 100644
--- a/lib/routes/cs/index.ts
+++ b/lib/routes/cs/index.ts
@@ -92,7 +92,7 @@ async function handler(ctx) {
return {
title: item.find('h3').text().trim(),
link: new URL(item.prop('href'), currentUrl).href,
- pubDate: timezone(parseDate(item.find('em').text()), +8),
+ pubDate: timezone(parseDate(item.find('em').text()), 8),
};
});
@@ -113,7 +113,7 @@ async function handler(ctx) {
.slice(1)
.toArray()
.map((c) => content(c).prop('title') ?? content(c).text());
- item.pubDate = timezone(parseDate(content('.time').prop('datetime')), +8);
+ item.pubDate = timezone(parseDate(content('.time').prop('datetime')), 8);
} catch {
// no-empty
}
diff --git a/lib/routes/cs/video.ts b/lib/routes/cs/video.ts
index e298ca23c..3475e4551 100644
--- a/lib/routes/cs/video.ts
+++ b/lib/routes/cs/video.ts
@@ -64,8 +64,8 @@ async function handler(ctx) {
link: new URL(item.contentUrl, rootUrl).href,
description: item.contentDetails,
author: item.contentSource,
- pubDate: timezone(parseDate(item.contentDatetime), +8),
- updated: timezone(parseDate(item.updateDate), +8),
+ pubDate: timezone(parseDate(item.contentDatetime), 8),
+ updated: timezone(parseDate(item.updateDate), 8),
}));
const { data: currentResponse } = await got(currentUrl);
diff --git a/lib/routes/cztv/daily.tsx b/lib/routes/cztv/daily.tsx
index 61c820a86..dc96588c6 100644
--- a/lib/routes/cztv/daily.tsx
+++ b/lib/routes/cztv/daily.tsx
@@ -57,7 +57,7 @@ async function handler() {
return {
title,
link,
- pubDate: timezone(parseDate(item.find('span.t2').text() + ' 16:30', 'YYYY-MM-DD hh:mm'), +8),
+ pubDate: timezone(parseDate(item.find('span.t2').text() + ' 16:30', 'YYYY-MM-DD hh:mm'), 8),
};
});
diff --git a/lib/routes/cztv/zjxwlb.tsx b/lib/routes/cztv/zjxwlb.tsx
index 989e46d2d..b2a777b29 100644
--- a/lib/routes/cztv/zjxwlb.tsx
+++ b/lib/routes/cztv/zjxwlb.tsx
@@ -55,7 +55,7 @@ async function handler() {
return {
title,
link,
- pubDate: timezone(parseDate(item.find('span.t2').text() + ' 16:30', 'YYYY-MM-DD hh:mm'), +8),
+ pubDate: timezone(parseDate(item.find('span.t2').text() + ' 16:30', 'YYYY-MM-DD hh:mm'), 8),
description: renderDesc({ title, videoUrl, posterUrl }),
};
});
diff --git a/lib/routes/dangdang/notice.ts b/lib/routes/dangdang/notice.ts
index 1de1063b2..e68baf115 100644
--- a/lib/routes/dangdang/notice.ts
+++ b/lib/routes/dangdang/notice.ts
@@ -48,7 +48,7 @@ async function handler(ctx) {
documentId: item.documentId,
source: `https://open.dangdang.com/op-api/developer-platform/document/info/get?document_id=${item.documentId}`,
link: `https://open.dangdang.com/home/notice/message/1/${item.documentId}`,
- pubDate: timezone(parseDate(item.modifyTime), +8),
+ pubDate: timezone(parseDate(item.modifyTime), 8),
}));
const result = await Promise.all(
diff --git a/lib/routes/dapenti/utils.ts b/lib/routes/dapenti/utils.ts
index 0b69eefb1..9cbc28a5f 100644
--- a/lib/routes/dapenti/utils.ts
+++ b/lib/routes/dapenti/utils.ts
@@ -60,7 +60,7 @@ export default {
title: el.text(),
author: pubInfo[0].trim(),
description: description.html(),
- pubDate: timezone(parseDate(pubInfo[1]?.trim()), +8),
+ pubDate: timezone(parseDate(pubInfo[1]?.trim()), 8),
link: url,
};
return single;
diff --git a/lib/routes/dayanzai/index.ts b/lib/routes/dayanzai/index.ts
index 11db2149f..dfd56492f 100644
--- a/lib/routes/dayanzai/index.ts
+++ b/lib/routes/dayanzai/index.ts
@@ -56,7 +56,7 @@ async function handler(ctx) {
}
return {
title: item.find('div.r > p.r-top > span > a').text(),
- pubDate: timezone(date, +8),
+ pubDate: timezone(date, 8),
description: item.find('div.r > p.desc').text(),
link: item.find('div.r > p.r-top > span > a').attr('href'),
};
diff --git a/lib/routes/dbaplus/new.ts b/lib/routes/dbaplus/new.ts
index c7c4352f3..5d6d5379c 100644
--- a/lib/routes/dbaplus/new.ts
+++ b/lib/routes/dbaplus/new.ts
@@ -113,14 +113,14 @@ export const handler = async (ctx: Context): Promise => {
const processedItem: DataItem = {
title,
description,
- pubDate: pubDateStr ? timezone(parseDate(pubDateStr), +8) : item.pubDate,
+ pubDate: pubDateStr ? timezone(parseDate(pubDateStr), 8) : item.pubDate,
category: categories,
author: authors,
content: {
html: description,
text: description,
},
- updated: upDatedStr ? timezone(parseDate(upDatedStr), +8) : item.updated,
+ updated: upDatedStr ? timezone(parseDate(upDatedStr), 8) : item.updated,
language,
};
diff --git a/lib/routes/ddosi/index.ts b/lib/routes/ddosi/index.ts
index 7035be4d5..e1e20c0a1 100644
--- a/lib/routes/ddosi/index.ts
+++ b/lib/routes/ddosi/index.ts
@@ -24,7 +24,7 @@ async function handler() {
const url = 'https://www.ddosi.org/';
const response = await got({
method: 'get',
- url: String(url),
+ url,
headers: {
Referer: url,
},
@@ -51,7 +51,7 @@ async function handler() {
return {
title: '雨苁',
- link: String(url),
+ link: url,
item: items,
};
}
diff --git a/lib/routes/decrypt/index.ts b/lib/routes/decrypt/index.ts
index e54e29fd0..78fef7c0e 100644
--- a/lib/routes/decrypt/index.ts
+++ b/lib/routes/decrypt/index.ts
@@ -89,7 +89,7 @@ async function handler(ctx): Promise {
} as Data;
}
-async function extractFullText(url: string): Promise {
+async function extractFullText(url: string): Promise<{ fullText: string; featuredImage: string; tags: string[] } | null> {
try {
const response = await ofetch(url);
diff --git a/lib/routes/dedao/knowledge.tsx b/lib/routes/dedao/knowledge.tsx
index d5eb7c28c..6651fc48b 100644
--- a/lib/routes/dedao/knowledge.tsx
+++ b/lib/routes/dedao/knowledge.tsx
@@ -5,7 +5,7 @@ import type { Route } from '@/types';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
-const mentionPattern = /<\u2267\u2746>\{"name":"(.*?)","uid":"\d+","at":"1"\}<\/\u2266\u2746>/g;
+const mentionPattern = /<\u{2267}\u{2746}>\{"name":"(.*?)","uid":"\d+","at":"1"\}<\/\u{2266}\u{2746}>/gu;
const formatNoteText = (text = '') => text.replaceAll('\n\n', '
').replaceAll(mentionPattern, ' @$1');
diff --git a/lib/routes/dedao/user.tsx b/lib/routes/dedao/user.tsx
index 39ebb3772..5a27fd7ab 100644
--- a/lib/routes/dedao/user.tsx
+++ b/lib/routes/dedao/user.tsx
@@ -11,7 +11,7 @@ const types = {
12: '视频',
};
-const mentionPattern = /<\u2267\u2746>\{"name":"(.*?)","uid":"\d+","at":"1"\}<\/\u2266\u2746>/g;
+const mentionPattern = /<\u{2267}\u{2746}>\{"name":"(.*?)","uid":"\d+","at":"1"\}<\/\u{2266}\u{2746}>/gu;
const formatNoteText = (text = '') => text.replaceAll('\n\n', '
').replaceAll(mentionPattern, ' @$1');
diff --git a/lib/routes/denonbu/news.ts b/lib/routes/denonbu/news.ts
index deadcf2e3..01baaefbe 100644
--- a/lib/routes/denonbu/news.ts
+++ b/lib/routes/denonbu/news.ts
@@ -176,7 +176,7 @@ async function handler(ctx: Context): Promise {
const result: DataItem = {
title: title ?? body.split('\n', 1)[0],
description: body,
- pubDate: timezone(parseDate(post_date), +9),
+ pubDate: timezone(parseDate(post_date), 9),
category: category.map((x) => x.name),
};
diff --git a/lib/routes/dewu/declaration.ts b/lib/routes/dewu/declaration.ts
index 0ab73bc25..c73d5cbc3 100644
--- a/lib/routes/dewu/declaration.ts
+++ b/lib/routes/dewu/declaration.ts
@@ -56,7 +56,7 @@ async function handler(ctx) {
title: item.title,
id: item.id,
link: `https://open.dewu.com/#/declaration/read?articleId=${item.id}`,
- pubDate: timezone(parseDate(item.publishTime), +8),
+ pubDate: timezone(parseDate(item.publishTime), 8),
}));
const result = await Promise.all(
diff --git a/lib/routes/dgjyw/index.ts b/lib/routes/dgjyw/index.ts
index b4633b706..57b3c5c0b 100644
--- a/lib/routes/dgjyw/index.ts
+++ b/lib/routes/dgjyw/index.ts
@@ -49,7 +49,7 @@ async function handler(ctx) {
content('.cont-tit').remove();
content('.art-body').html(content('.v_news_content').html());
- item.pubDate = timezone(parseDate(content('meta[name="PubDate"]').attr('content')), +8);
+ item.pubDate = timezone(parseDate(content('meta[name="PubDate"]').attr('content')), 8);
item.description = content('form[name="_newscontent_fromname"]').html();
}
diff --git a/lib/routes/dgtle/video.ts b/lib/routes/dgtle/video.ts
index 273f4c3c6..a88fe00b8 100644
--- a/lib/routes/dgtle/video.ts
+++ b/lib/routes/dgtle/video.ts
@@ -117,7 +117,7 @@ export const handler = async (ctx: Context): Promise => {
let processedItem: DataItem = {
title,
description,
- pubDate: pubDateStr ? timezone(parseRelativeDate(pubDateStr), +8) : item.pubDate,
+ pubDate: pubDateStr ? timezone(parseRelativeDate(pubDateStr), 8) : item.pubDate,
link: linkUrl ? new URL(linkUrl, baseUrl).href : item.link,
category: categories,
author: authors,
@@ -130,7 +130,7 @@ export const handler = async (ctx: Context): Promise => {
},
image,
banner: image,
- updated: upDatedStr ? timezone(parseRelativeDate(upDatedStr), +8) : item.updated,
+ updated: upDatedStr ? timezone(parseRelativeDate(upDatedStr), 8) : item.updated,
language,
};
diff --git a/lib/routes/dlsite/ci-en/article.ts b/lib/routes/dlsite/ci-en/article.ts
index b05eb3dc6..ee8642c82 100644
--- a/lib/routes/dlsite/ci-en/article.ts
+++ b/lib/routes/dlsite/ci-en/article.ts
@@ -75,7 +75,7 @@ async function handler(ctx) {
});
item.description = content('article').html();
- item.pubDate = timezone(parseDate(content('.e-date').first().text()), +9);
+ item.pubDate = timezone(parseDate(content('.e-date').first().text()), 9);
item.category = content('.c-hashTagList-item')
.toArray()
.map((t) => content(t).text().split('#').pop().trim());
diff --git a/lib/routes/dlsite/utils.ts b/lib/routes/dlsite/utils.ts
index b13e050f0..115743fe8 100644
--- a/lib/routes/dlsite/utils.ts
+++ b/lib/routes/dlsite/utils.ts
@@ -127,9 +127,9 @@ const ProcessItems = async (ctx) => {
const detail = details[guid];
- const pubDate = timezone(parseDate(detail.regist_date), +9);
+ const pubDate = timezone(parseDate(detail.regist_date), 9);
const discountRate = detail.discount_rate;
- const discountEndDate = detail.discount_end_date ? timezone(parseDate(detail.discount_end_date, 'MM/DD HH:mm'), +9) : undefined;
+ const discountEndDate = detail.discount_end_date ? timezone(parseDate(detail.discount_end_date, 'MM/DD HH:mm'), 9) : undefined;
images = images.length === 0 ? [detail.work_image] : images;
return {
diff --git a/lib/routes/dmzj/news.ts b/lib/routes/dmzj/news.ts
index 90fce6d40..03f72e609 100644
--- a/lib/routes/dmzj/news.ts
+++ b/lib/routes/dmzj/news.ts
@@ -46,7 +46,7 @@ async function handler(ctx) {
title: $(item).find('h3 a').text(),
link: $(item).find('h3 a').attr('href'),
author: $(item).find('.head_con_p_o span:nth-child(3)').text().split(':', 2)[1],
- pubDate: timezone(parseDate($(item).find('.head_con_p_o span').first().text(), 'YYYY-MM-DD HH:mm'), +8),
+ pubDate: timezone(parseDate($(item).find('.head_con_p_o span').first().text(), 'YYYY-MM-DD HH:mm'), 8),
description: $(item).find('p.com_about').text(),
category: $(item)
.find('.u_comfoot a .bqwarp')
diff --git a/lib/routes/dn/news.ts b/lib/routes/dn/news.ts
index fd20461d6..d20e9a91f 100644
--- a/lib/routes/dn/news.ts
+++ b/lib/routes/dn/news.ts
@@ -75,7 +75,7 @@ async function handler(ctx) {
.find('span.cat')
.toArray()
.map((c) => $(c).text()),
- pubDate: timezone(parseDate(item.find('span.time').text()), +8),
+ pubDate: timezone(parseDate(item.find('span.time').text()), 8),
};
});
@@ -100,7 +100,7 @@ async function handler(ctx) {
.toArray()
.map((c) => content(c).text()),
];
- item.pubDate = timezone(parseDate(content('span.date').text()), +8);
+ item.pubDate = timezone(parseDate(content('span.date').text()), 8);
return item;
})
diff --git a/lib/routes/dnaindia/common.ts b/lib/routes/dnaindia/common.ts
index 180919d42..045efc462 100644
--- a/lib/routes/dnaindia/common.ts
+++ b/lib/routes/dnaindia/common.ts
@@ -47,7 +47,7 @@ export async function handler(ctx) {
const dateMatch = timeText.match(/Updated\s*:([\w\s,:]+)/);
let time = dateMatch ? dateMatch[1].trim() : '';
time = time.replace(/\s+IST$/, '');
- const pubDate = timezone(parseDate(time), +5.5);
+ const pubDate = timezone(parseDate(time), 5.5);
// Get author information
const authorMeta = $('meta[name="author"]').attr('content');
const author = authorMeta || 'DNA Web Team';
diff --git a/lib/routes/dol/announce.ts b/lib/routes/dol/announce.ts
index a76e5f44d..40f0f9f09 100644
--- a/lib/routes/dol/announce.ts
+++ b/lib/routes/dol/announce.ts
@@ -95,7 +95,7 @@ async function handler(ctx) {
Number.parseInt(dateList[1]) - 1,
Number.parseInt(dateList[0])
),
- +7
+ 7
),
author: officeName.text(),
category: [reqType.text()],
diff --git a/lib/routes/domp4/utils.ts b/lib/routes/domp4/utils.ts
index 7e446b8b8..04ec09a53 100644
--- a/lib/routes/domp4/utils.ts
+++ b/lib/routes/domp4/utils.ts
@@ -61,6 +61,7 @@ function getUrlType(url) {
*/
function decodeCipherText(p, a, c, k, e, d) {
e = function (c) {
+ // oxlint-disable-next-line unicorn-js/operator-assignment
return (c < a ? '' : e(Number.parseInt((c / a).toString()))) + ((c = c % a) > 35 ? String.fromCodePoint(c + 29) : c.toString(36));
};
if (!''.replace(/^/, () => '')) {
diff --git a/lib/routes/dora-world/article.ts b/lib/routes/dora-world/article.ts
index dbf80b6a0..96db87406 100644
--- a/lib/routes/dora-world/article.ts
+++ b/lib/routes/dora-world/article.ts
@@ -51,7 +51,7 @@ async function handler(ctx): Promise {
title: item.title,
link: item.page_url.startsWith('http') ? item.page_url : `${baseUrl}${item.page_url}`,
description: item.page_url.startsWith('/contents/') ? '' : `${item.title}
`,
- pubDate: timezone(parseDate(item.publish_at), +9),
+ pubDate: timezone(parseDate(item.publish_at), 9),
category: item.tags.map((tag) => tag.name),
guid: item.id,
}));
@@ -85,6 +85,6 @@ async function getContent(nextBuildId: string, contentId: string) {
content
.html()
?.replaceAll(rubyRegex, '$1($2)')
- ?.replaceAll(/[^\t\n\r\u0020-\uD7FF\uE000-\uFDCF\uFDE0-\uFFFD]/g, '') ?? '';
+ ?.replaceAll(/[^\t\n\r\u{0020}-\u{D7FF}\u{E000}-\u{FDCF}\u{FDE0}-\u{FFFD}]/gu, '') ?? '';
return description;
}
diff --git a/lib/routes/douban/other/replied.ts b/lib/routes/douban/other/replied.ts
index c231d97ee..bf28f17fb 100644
--- a/lib/routes/douban/other/replied.ts
+++ b/lib/routes/douban/other/replied.ts
@@ -69,7 +69,8 @@ async function handler(ctx) {
pubDate,
author;
- for (const c of comments) {
+ while (comments.length > 0) {
+ const c = comments.shift();
if (c.author.uid === ctx.req.param('uid') && new Date(c.create_time) > new Date(latest)) {
latest = new Date(c.create_time + ' GMT+8');
pubDate = latest.toUTCString();
diff --git a/lib/routes/douban/other/replies.ts b/lib/routes/douban/other/replies.ts
index 098f5509e..a330635f2 100644
--- a/lib/routes/douban/other/replies.ts
+++ b/lib/routes/douban/other/replies.ts
@@ -57,7 +57,8 @@ async function handler(ctx) {
const comments = JSON.parse(detailResponse.data.match(/'comments':(.*)\}\],/)[1] + '}]');
- for (const c of comments) {
+ while (comments.length > 0) {
+ const c = comments.shift();
if (c.id === item.link.split('#', 2)[1]) {
return {
link: item.link,
diff --git a/lib/routes/douyin/hashtag.ts b/lib/routes/douyin/hashtag.ts
index 77541e05e..f1ef14cb9 100644
--- a/lib/routes/douyin/hashtag.ts
+++ b/lib/routes/douyin/hashtag.ts
@@ -88,13 +88,13 @@ async function handler(ctx) {
videoList = videoList.map((item) => proxyVideo(item, relay));
}
let duration = post.video && post.video.duration;
- duration = duration && duration / 1000;
+ duration &&= duration / 1000;
let img;
// if (!embed) {
// img = post.video && post.video.dynamic_cover && post.video.dynamic_cover.url_list[post.video.dynamic_cover.url_list.length - 1]; // dynamic cover (webp)
// }
- img = img || (post.video && post.video.origin_cover && post.video.origin_cover.url_list.at(-1));
- img = img && resolveUrl(img);
+ img ||= post.video && post.video.origin_cover && post.video.origin_cover.url_list.at(-1);
+ img &&= resolveUrl(img);
// render description
const desc = post.desc && post.desc.replaceAll('\n', '
');
diff --git a/lib/routes/douyin/user.ts b/lib/routes/douyin/user.ts
index ca0a020e8..f4421eb00 100644
--- a/lib/routes/douyin/user.ts
+++ b/lib/routes/douyin/user.ts
@@ -95,16 +95,15 @@ async function handler(ctx) {
videoList = videoList.map((item) => proxyVideo(item, relay));
}
let duration = post.video?.duration;
- duration = duration && duration / 1000;
+ duration &&= duration / 1000;
let img;
// if (!embed) {
// img = post.video && post.video.dynamicCover; // dynamic cover (webp)
// }
- img =
- img ||
+ img ||=
post.video?.cover?.url_list.at(-1) || // HD
post.video?.origin_cover?.url_list.at(-1); // LD
- img = img && resolveUrl(img);
+ img &&= resolveUrl(img);
// render description
const desc = post.desc?.replaceAll('\n', '
');
diff --git a/lib/routes/douyu/group.ts b/lib/routes/douyu/group.ts
index 93893ebff..631a4e53b 100644
--- a/lib/routes/douyu/group.ts
+++ b/lib/routes/douyu/group.ts
@@ -54,7 +54,7 @@ async function handler(ctx) {
const items = response.data.data.map((item) => ({
title: item.title,
link: `${rootUrl}/p/${item.post_id}`,
- pubDate: timezone(parseDate(item.created_at_std), +8),
+ pubDate: timezone(parseDate(item.created_at_std), 8),
description: renderDescription({
content: item.describe,
images: item.imglist.map((i) => ({
diff --git a/lib/routes/dpm/exhibitions.tsx b/lib/routes/dpm/exhibitions.tsx
index 5aa2a3de4..dd9053744 100644
--- a/lib/routes/dpm/exhibitions.tsx
+++ b/lib/routes/dpm/exhibitions.tsx
@@ -126,7 +126,7 @@ export const route: Route = {
fullDuration = '未定/常设';
}
- const cleanDuration = fullDuration.replaceAll('.', '-').replaceAll('/', '-');
+ const cleanDuration = fullDuration.replaceAll(/[./]/g, '-');
// use YYYY-MM-DD for date format
const dateMatches = cleanDuration.match(/\d{4}-\d{2}-\d{2}/g);
diff --git a/lib/routes/duozhi/index.ts b/lib/routes/duozhi/index.ts
index 1e873ea0c..39688307b 100644
--- a/lib/routes/duozhi/index.ts
+++ b/lib/routes/duozhi/index.ts
@@ -135,7 +135,7 @@ export const handler = async (ctx: Context): Promise => {
const processedItem: DataItem = {
title,
description,
- pubDate: pubDateStr ? timezone(parseDate(pubDateStr), +8) : item.pubDate,
+ pubDate: pubDateStr ? timezone(parseDate(pubDateStr), 8) : item.pubDate,
category: categories,
author: authors,
content: {
@@ -144,7 +144,7 @@ export const handler = async (ctx: Context): Promise => {
},
image,
banner: image,
- updated: upDatedStr ? timezone(parseDate(upDatedStr), +8) : item.updated,
+ updated: upDatedStr ? timezone(parseDate(upDatedStr), 8) : item.updated,
language,
};
diff --git a/lib/routes/dykszx/news.ts b/lib/routes/dykszx/news.ts
index d9f2273e3..2199dfe86 100644
--- a/lib/routes/dykszx/news.ts
+++ b/lib/routes/dykszx/news.ts
@@ -47,7 +47,7 @@ async function handler(ctx) {
title: item.children[0].children[0].data,
description: newsContent.content,
link: newsContent.newsPage,
- pubDate: timezone(parseDate(newsContent.newsTime, '时间:YYYY-MM-DD HH:mm:ss'), +8),
+ pubDate: timezone(parseDate(newsContent.newsTime, '时间:YYYY-MM-DD HH:mm:ss'), 8),
};
});
})
diff --git a/lib/routes/dytt/index.ts b/lib/routes/dytt/index.ts
index 882d20c27..0801008da 100644
--- a/lib/routes/dytt/index.ts
+++ b/lib/routes/dytt/index.ts
@@ -43,14 +43,14 @@ export const handler = async (ctx: Context): Promise => {
const processedItem: DataItem = {
title,
description,
- pubDate: pubDateStr ? timezone(parseDate(pubDateStr), +8) : undefined,
+ pubDate: pubDateStr ? timezone(parseDate(pubDateStr), 8) : undefined,
link: linkUrl ? new URL(linkUrl, baseUrl).href : undefined,
doi: $el.find('meta[name="citation_doi"]').attr('content'),
content: {
html: description,
text: description,
},
- updated: upDatedStr ? timezone(parseDate(upDatedStr), +8) : undefined,
+ updated: upDatedStr ? timezone(parseDate(upDatedStr), 8) : undefined,
language,
};
diff --git a/lib/routes/eagle/changelog.ts b/lib/routes/eagle/changelog.ts
index be577c12c..a132e2e56 100644
--- a/lib/routes/eagle/changelog.ts
+++ b/lib/routes/eagle/changelog.ts
@@ -38,8 +38,7 @@ async function handler(ctx) {
}
if (language === 'tw') {
changelog = '更新日誌';
- }
- if (language === 'en') {
+ } else if (language === 'en') {
changelog = 'Release Notes';
}
diff --git a/lib/routes/earthquake/ceic.ts b/lib/routes/earthquake/ceic.ts
index ff980d1e9..51f6acbbf 100644
--- a/lib/routes/earthquake/ceic.ts
+++ b/lib/routes/earthquake/ceic.ts
@@ -41,7 +41,7 @@ export const route: Route = {
async function handler(ctx) {
let type = Number(ctx.req.param('type'));
- type = type ?? 1;
+ type ??= 1;
const baseUrl = 'http://www.ceic.ac.cn';
const api = `${baseUrl}/ajax/speedsearch?num=${type}`;
const mappings = {
@@ -96,7 +96,7 @@ async function handler(ctx) {
return {
title: `${LOCATION_C}发生${M}级地震`,
link: `${baseUrl}/${NEW_DID}.html`,
- pubDate: timezone(parseDate(O_TIME, 'YYYY-MM-DD HH:mm:ss'), +8),
+ pubDate: timezone(parseDate(O_TIME, 'YYYY-MM-DD HH:mm:ss'), 8),
description: contentBuilder.join('
'),
guid: NEW_DID,
};
diff --git a/lib/routes/earthquake/index.ts b/lib/routes/earthquake/index.ts
index 3dfc0b7df..a13c841dd 100644
--- a/lib/routes/earthquake/index.ts
+++ b/lib/routes/earthquake/index.ts
@@ -54,7 +54,7 @@ async function handler(ctx) {
return {
title: `${epicenter}发生${num}级地震`,
link: `https://www.cea.gov.cn/eportal/ui?struts.portlet.mode=view&struts.portlet.action=/portlet/expressEarthquake!toNewInfoView.action&pageId=366521&id=${id}`,
- pubDate: timezone(parseDate(date, 'YYYY-MM-DD HH:mm:ss'), +8),
+ pubDate: timezone(parseDate(date, 'YYYY-MM-DD HH:mm:ss'), 8),
description,
};
});
diff --git a/lib/routes/eastday/24.ts b/lib/routes/eastday/24.ts
index 087f48ff9..3d89b9aa9 100644
--- a/lib/routes/eastday/24.ts
+++ b/lib/routes/eastday/24.ts
@@ -86,7 +86,7 @@ async function handler(ctx) {
const pageNumber = Number.parseInt(detailResponse.data.match(/var page_num = '(\d+)'/)[1]);
item.description = content('#J-contain_detail_cnt').html();
- item.pubDate = timezone(parseDate(content('meta[property="og:release_date"]').attr('content')), +8);
+ item.pubDate = timezone(parseDate(content('meta[property="og:release_date"]').attr('content')), 8);
if (pageNumber > 1) {
const links = [];
diff --git a/lib/routes/eastday/portrait.ts b/lib/routes/eastday/portrait.ts
index d68172890..ae9dc2768 100644
--- a/lib/routes/eastday/portrait.ts
+++ b/lib/routes/eastday/portrait.ts
@@ -46,7 +46,7 @@ async function handler() {
const list = response.data.list.map((item) => ({
link: item.url,
title: item.title,
- pubDate: timezone(parseDate(item.time), +8),
+ pubDate: timezone(parseDate(item.time), 8),
}));
const items = await Promise.all(
diff --git a/lib/routes/eastday/sh.ts b/lib/routes/eastday/sh.ts
index 7c875f2dd..115be82e6 100644
--- a/lib/routes/eastday/sh.ts
+++ b/lib/routes/eastday/sh.ts
@@ -45,7 +45,7 @@ async function handler() {
const entity = {
title: item.title,
description: item.abstracts,
- pubDate: timezone(parseDate(item.time), +8),
+ pubDate: timezone(parseDate(item.time), 8),
link,
};
diff --git a/lib/routes/eastmoney/ttjj/user.ts b/lib/routes/eastmoney/ttjj/user.ts
index 35d650993..37e7728b8 100644
--- a/lib/routes/eastmoney/ttjj/user.ts
+++ b/lib/routes/eastmoney/ttjj/user.ts
@@ -71,7 +71,7 @@ async function handler(ctx) {
const single = {
title: item.post_title,
description,
- pubDate: timezone(parseDate(item.post_display_time, 'YYYY-MM-DD HH:mm:ss'), +8),
+ pubDate: timezone(parseDate(item.post_display_time, 'YYYY-MM-DD HH:mm:ss'), 8),
link: `https://fundbarmob.eastmoney.com/index.html?goPage=articleView&lastPage=personDetailView&aid=${item.post_id}`,
};
return single;
diff --git a/lib/routes/ecnu/art.ts b/lib/routes/ecnu/art.ts
index c4afb5bd0..d4069f729 100644
--- a/lib/routes/ecnu/art.ts
+++ b/lib/routes/ecnu/art.ts
@@ -28,7 +28,7 @@ export const route: Route = {
const links = $('ul.data-list > li')
.toArray()
.map((el) => ({
- pubDate: timezone(parseDate($(el).find('span').text()), +8),
+ pubDate: timezone(parseDate($(el).find('span').text()), 8),
link: new URL($(el).find('a').attr('href'), baseUrl).href,
title: $(el).find('a').text(),
}));
diff --git a/lib/routes/ecnu/bksy.ts b/lib/routes/ecnu/bksy.ts
index e08af2e14..71f45cc62 100644
--- a/lib/routes/ecnu/bksy.ts
+++ b/lib/routes/ecnu/bksy.ts
@@ -26,7 +26,7 @@ export const route: Route = {
const links = $('ul.news_list.list2 > li')
.toArray()
.map((el) => ({
- pubDate: timezone(parseDate($(el).find('.news_date').text()), +8),
+ pubDate: timezone(parseDate($(el).find('.news_date').text()), 8),
link: new URL($(el).find('a').attr('href'), baseUrl).href,
title: $(el).find('.news_title').text(),
}));
diff --git a/lib/routes/ecnu/cee.ts b/lib/routes/ecnu/cee.ts
index f1b4530f3..72910d18e 100644
--- a/lib/routes/ecnu/cee.ts
+++ b/lib/routes/ecnu/cee.ts
@@ -26,7 +26,7 @@ export const route: Route = {
const links = $('ul.news_list.list2 > li')
.toArray()
.map((el) => ({
- pubDate: timezone(parseDate($(el).find('.news_meta').text()), +8),
+ pubDate: timezone(parseDate($(el).find('.news_meta').text()), 8),
link: new URL($(el).find('a').attr('href'), baseUrl).href,
title: $(el).find('a').text(),
}));
diff --git a/lib/routes/ecnu/chem.ts b/lib/routes/ecnu/chem.ts
index 53405feb8..fe255e7b5 100644
--- a/lib/routes/ecnu/chem.ts
+++ b/lib/routes/ecnu/chem.ts
@@ -28,7 +28,7 @@ export const route: Route = {
const links = $('ul.cols_list.clearfix > li')
.toArray()
.map((el) => ({
- pubDate: timezone(parseDate($(el).find('.cols_meta').text()), +8),
+ pubDate: timezone(parseDate($(el).find('.cols_meta').text()), 8),
link: new URL($(el).find('a').attr('href'), baseUrl).href,
title: $(el).find('a').text(),
}));
diff --git a/lib/routes/ecnu/chinese.ts b/lib/routes/ecnu/chinese.ts
index 36c379fe8..c3d64dc91 100644
--- a/lib/routes/ecnu/chinese.ts
+++ b/lib/routes/ecnu/chinese.ts
@@ -28,7 +28,7 @@ export const route: Route = {
const links = $('ul.news_list.list2 > li')
.toArray()
.map((el) => ({
- pubDate: timezone(parseDate($(el).find('.news_meta').text()), +8),
+ pubDate: timezone(parseDate($(el).find('.news_meta').text()), 8),
link: new URL($(el).find('a').attr('href'), baseUrl).href,
title: $(el).find('a').attr('title'),
}));
diff --git a/lib/routes/ecnu/comm.ts b/lib/routes/ecnu/comm.ts
index 3785a6c98..2a077c302 100644
--- a/lib/routes/ecnu/comm.ts
+++ b/lib/routes/ecnu/comm.ts
@@ -26,7 +26,7 @@ export const route: Route = {
const links = $('ul.news_list.list2 > li')
.toArray()
.map((el) => ({
- pubDate: timezone(parseDate($(el).find('.news_meta').text()), +8),
+ pubDate: timezone(parseDate($(el).find('.news_meta').text()), 8),
link: new URL($(el).find('a').attr('href'), baseUrl).href,
title: $(el).find('a').text(),
}));
diff --git a/lib/routes/ecnu/cs.ts b/lib/routes/ecnu/cs.ts
index e4cbabdb5..65604f2d9 100644
--- a/lib/routes/ecnu/cs.ts
+++ b/lib/routes/ecnu/cs.ts
@@ -26,7 +26,7 @@ export const route: Route = {
const links = $('div#wp_news_w6 ul.data-list > li')
.toArray()
.map((el) => ({
- pubDate: timezone(parseDate($(el).find('span').text()), +8),
+ pubDate: timezone(parseDate($(el).find('span').text()), 8),
link: new URL($(el).find('a').attr('href'), baseUrl).href,
title: $(el).find('a').text(),
}));
diff --git a/lib/routes/ecnu/cxcy.ts b/lib/routes/ecnu/cxcy.ts
index decc0f497..b1fc8c20d 100644
--- a/lib/routes/ecnu/cxcy.ts
+++ b/lib/routes/ecnu/cxcy.ts
@@ -49,7 +49,7 @@ export const route: Route = {
const filteredEls = $(`div.limit_style1[frag="${fragList[type].frag}"]`).find('table > tbody > tr > td').toArray();
const links = filteredEls.map((el) => ({
- pubDate: timezone(parseDate($(el).find('.data').text()), +8),
+ pubDate: timezone(parseDate($(el).find('.data').text()), 8),
link: new URL($(el).find('a').attr('href'), baseUrl).href,
title: $(el).find('.news_title').text(),
}));
diff --git a/lib/routes/ecnu/dase.ts b/lib/routes/ecnu/dase.ts
index 6bb77f0ff..ffd5f6ecb 100644
--- a/lib/routes/ecnu/dase.ts
+++ b/lib/routes/ecnu/dase.ts
@@ -26,7 +26,7 @@ export const route: Route = {
const links = $('ul.news_list.list2 > li')
.toArray()
.map((el) => ({
- pubDate: timezone(parseDate($(el).find('.news_meta').text()), +8),
+ pubDate: timezone(parseDate($(el).find('.news_meta').text()), 8),
link: new URL($(el).find('a').attr('href'), baseUrl).href,
title: $(el).find('a').text(),
}));
diff --git a/lib/routes/ecnu/dx.ts b/lib/routes/ecnu/dx.ts
index 8c6fe80bf..19c359650 100644
--- a/lib/routes/ecnu/dx.ts
+++ b/lib/routes/ecnu/dx.ts
@@ -26,7 +26,7 @@ export const route: Route = {
const links = $('ul.news_list.list2 > li')
.toArray()
.map((el) => ({
- pubDate: timezone(parseDate($(el).find('.news_meta').text()), +8),
+ pubDate: timezone(parseDate($(el).find('.news_meta').text()), 8),
link: new URL($(el).find('a').attr('href'), baseUrl).href,
title: $(el).find('a').text(),
}));
diff --git a/lib/routes/ecnu/dxb.ts b/lib/routes/ecnu/dxb.ts
index 3bbf32368..b924a5a77 100644
--- a/lib/routes/ecnu/dxb.ts
+++ b/lib/routes/ecnu/dxb.ts
@@ -28,7 +28,7 @@ export const route: Route = {
const links = $('ul.news_list > li')
.toArray()
.map((el) => ({
- pubDate: timezone(parseDate($(el).find('.news_meta').text()), +8),
+ pubDate: timezone(parseDate($(el).find('.news_meta').text()), 8),
link: new URL($(el).find('a').attr('href'), baseUrl).href,
title: $(el).find('a').text(),
}));
diff --git a/lib/routes/ecnu/ed.ts b/lib/routes/ecnu/ed.ts
index 0312caf9f..510088a06 100644
--- a/lib/routes/ecnu/ed.ts
+++ b/lib/routes/ecnu/ed.ts
@@ -26,7 +26,7 @@ export const route: Route = {
const links = $('ul.news_list.list2 > li')
.toArray()
.map((el) => ({
- pubDate: timezone(parseDate($(el).find('.news_meta').text()), +8),
+ pubDate: timezone(parseDate($(el).find('.news_meta').text()), 8),
link: new URL($(el).find('a').attr('href'), baseUrl).href,
title: $(el).find('a').text(),
}));
diff --git a/lib/routes/ecnu/geoai.ts b/lib/routes/ecnu/geoai.ts
index c67e30bb9..16a447e44 100644
--- a/lib/routes/ecnu/geoai.ts
+++ b/lib/routes/ecnu/geoai.ts
@@ -28,7 +28,7 @@ export const route: Route = {
const links = $('ul.news_list > li')
.toArray()
.map((el) => ({
- pubDate: timezone(parseDate($(el).find('.news_meta').text()), +8),
+ pubDate: timezone(parseDate($(el).find('.news_meta').text()), 8),
link: new URL($(el).find('a').attr('href'), baseUrl).href,
title: $(el).find('a').text(),
}));
diff --git a/lib/routes/ecnu/ghcollege.ts b/lib/routes/ecnu/ghcollege.ts
index 2271399b1..417bf1ab3 100644
--- a/lib/routes/ecnu/ghcollege.ts
+++ b/lib/routes/ecnu/ghcollege.ts
@@ -28,7 +28,7 @@ export const route: Route = {
const links = $('ul.wp_article_list > li')
.toArray()
.map((el) => ({
- pubDate: timezone(parseDate($(el).find('.Article_PublishDate').text()), +8),
+ pubDate: timezone(parseDate($(el).find('.Article_PublishDate').text()), 8),
link: new URL($(el).find('a').attr('href'), baseUrl).href,
title: $(el).find('a').text(),
}));
diff --git a/lib/routes/ecnu/history.ts b/lib/routes/ecnu/history.ts
index a48695bbc..7af7d5a64 100644
--- a/lib/routes/ecnu/history.ts
+++ b/lib/routes/ecnu/history.ts
@@ -26,7 +26,7 @@ export const route: Route = {
const links = $('ul.data-list2 > li')
.toArray()
.map((el) => ({
- pubDate: timezone(parseDate($(el).find('span').text()), +8),
+ pubDate: timezone(parseDate($(el).find('span').text()), 8),
link: new URL($(el).find('a').attr('href'), baseUrl).href,
title: $(el).find('a').text(),
}));
diff --git a/lib/routes/ecnu/jiaoliu.ts b/lib/routes/ecnu/jiaoliu.ts
index 2b3bd4512..b35ecccc2 100644
--- a/lib/routes/ecnu/jiaoliu.ts
+++ b/lib/routes/ecnu/jiaoliu.ts
@@ -26,7 +26,7 @@ export const route: Route = {
const links = $('#wp_news_w3 > table > tbody > tr')
.toArray()
.map((el) => ({
- pubDate: timezone(parseDate($(el).find('div[style="white-space:nowrap"]').text()), +8),
+ pubDate: timezone(parseDate($(el).find('div[style="white-space:nowrap"]').text()), 8),
link: new URL($(el).find('a').attr('href'), baseUrl).href,
title: $(el).find('a').text(),
}));
diff --git a/lib/routes/ecnu/jwc.ts b/lib/routes/ecnu/jwc.ts
index 9b11ae342..05602979a 100644
--- a/lib/routes/ecnu/jwc.ts
+++ b/lib/routes/ecnu/jwc.ts
@@ -54,11 +54,10 @@ export const route: Route = {
item.description = '请进行统一身份认证之后再访问';
return item;
}
- } else {
- // file to download
- item.description = '点击认证后访问内容';
- return item;
}
+ // file to download
+ item.description = '点击认证后访问内容';
+ return item;
})
)
);
diff --git a/lib/routes/ecnu/mks.ts b/lib/routes/ecnu/mks.ts
index 52226a2b1..3d56dec35 100644
--- a/lib/routes/ecnu/mks.ts
+++ b/lib/routes/ecnu/mks.ts
@@ -26,7 +26,7 @@ export const route: Route = {
const links = $('ul.news_list.list2 > li')
.toArray()
.map((el) => ({
- pubDate: timezone(parseDate($(el).find('.news_date').text()), +8),
+ pubDate: timezone(parseDate($(el).find('.news_date').text()), 8),
link: new URL($(el).find('a').attr('href'), baseUrl).href,
title: $(el).find('.news_title').text(),
}));
diff --git a/lib/routes/ecnu/mxcsy.ts b/lib/routes/ecnu/mxcsy.ts
index 14bb6fd34..5f7c0d972 100644
--- a/lib/routes/ecnu/mxcsy.ts
+++ b/lib/routes/ecnu/mxcsy.ts
@@ -26,7 +26,7 @@ export const route: Route = {
const links = $('ul.wp_article_list > li')
.toArray()
.map((el) => ({
- pubDate: timezone(parseDate($(el).find('.Article_PublishDate').text()), +8),
+ pubDate: timezone(parseDate($(el).find('.Article_PublishDate').text()), 8),
link: new URL($(el).find('a').attr('href'), baseUrl).href,
title: $(el).find('a').text(),
}));
diff --git a/lib/routes/ecnu/pharm.ts b/lib/routes/ecnu/pharm.ts
index b39c14f6d..bc8fa1cb3 100644
--- a/lib/routes/ecnu/pharm.ts
+++ b/lib/routes/ecnu/pharm.ts
@@ -28,7 +28,7 @@ export const route: Route = {
const links = $('ul.news_list.list2 > li')
.toArray()
.map((el) => ({
- pubDate: timezone(parseDate($(el).find('.news_meta').text()), +8),
+ pubDate: timezone(parseDate($(el).find('.news_meta').text()), 8),
link: new URL($(el).find('a').attr('href'), baseUrl).href,
title: $(el).find('a').text(),
}));
diff --git a/lib/routes/ecnu/philo.ts b/lib/routes/ecnu/philo.ts
index a567c9590..1fbc8d57c 100644
--- a/lib/routes/ecnu/philo.ts
+++ b/lib/routes/ecnu/philo.ts
@@ -26,7 +26,7 @@ export const route: Route = {
const links = $('ul.data-list2 > li')
.toArray()
.map((el) => ({
- pubDate: timezone(parseDate($(el).find('span').text()), +8),
+ pubDate: timezone(parseDate($(el).find('span').text()), 8),
link: new URL($(el).find('a').attr('href'), baseUrl).href,
title: $(el).find('a').text(),
}));
diff --git a/lib/routes/ecnu/phy.ts b/lib/routes/ecnu/phy.ts
index e070a50b4..528b483aa 100644
--- a/lib/routes/ecnu/phy.ts
+++ b/lib/routes/ecnu/phy.ts
@@ -26,7 +26,7 @@ export const route: Route = {
const links = $('ul.data-list > li')
.toArray()
.map((el) => ({
- pubDate: timezone(parseDate($(el).find('span').text()), +8),
+ pubDate: timezone(parseDate($(el).find('span').text()), 8),
link: new URL($(el).find('a').attr('href'), baseUrl).href,
title: $(el).find('a').attr('title'),
}));
diff --git a/lib/routes/ecnu/psy.ts b/lib/routes/ecnu/psy.ts
index 2fed52f9c..07b056125 100644
--- a/lib/routes/ecnu/psy.ts
+++ b/lib/routes/ecnu/psy.ts
@@ -26,7 +26,7 @@ export const route: Route = {
const links = $('ul.wp_article_list > li')
.toArray()
.map((el) => ({
- pubDate: timezone(parseDate($(el).find('.Article_PublishDate').text()), +8),
+ pubDate: timezone(parseDate($(el).find('.Article_PublishDate').text()), 8),
link: new URL($(el).find('a').attr('href'), baseUrl).href,
title: $(el).find('a').attr('title'),
}));
diff --git a/lib/routes/ecnu/sees.ts b/lib/routes/ecnu/sees.ts
index 429c71dec..fce7194d2 100644
--- a/lib/routes/ecnu/sees.ts
+++ b/lib/routes/ecnu/sees.ts
@@ -26,7 +26,7 @@ export const route: Route = {
const links = $('ul.news_list.list2 > li')
.toArray()
.map((el) => ({
- pubDate: timezone(parseDate($(el).find('.news_meta').text()), +8),
+ pubDate: timezone(parseDate($(el).find('.news_meta').text()), 8),
link: new URL($(el).find('a').attr('href'), baseUrl).href,
title: $(el).find('a').text(),
}));
diff --git a/lib/routes/ecnu/sei.ts b/lib/routes/ecnu/sei.ts
index 26973570a..5f5d367c1 100644
--- a/lib/routes/ecnu/sei.ts
+++ b/lib/routes/ecnu/sei.ts
@@ -26,7 +26,7 @@ export const route: Route = {
const links = $('ul.data-list > li')
.toArray()
.map((el) => ({
- pubDate: timezone(parseDate($(el).find('.data-list-time').text()), +8),
+ pubDate: timezone(parseDate($(el).find('.data-list-time').text()), 8),
link: new URL($(el).find('a').attr('href'), baseUrl).href,
title: $(el).find('a').text(),
}));
diff --git a/lib/routes/ecnu/spm.ts b/lib/routes/ecnu/spm.ts
index 8e1e7f73d..6ec3bcb6e 100644
--- a/lib/routes/ecnu/spm.ts
+++ b/lib/routes/ecnu/spm.ts
@@ -28,7 +28,7 @@ export const route: Route = {
const links = $('ul.news_list.list2 > li')
.toArray()
.map((el) => ({
- pubDate: timezone(parseDate($(el).find('.news_meta').text()), +8),
+ pubDate: timezone(parseDate($(el).find('.news_meta').text()), 8),
link: new URL($(el).find('a').attr('href'), baseUrl).href,
title: $(el).find('a').text(),
}));
diff --git a/lib/routes/ecnu/stat.ts b/lib/routes/ecnu/stat.ts
index 15f0e7090..f23ef39a7 100644
--- a/lib/routes/ecnu/stat.ts
+++ b/lib/routes/ecnu/stat.ts
@@ -26,7 +26,7 @@ export const route: Route = {
const links = $('ul.news_list.list2 > li')
.toArray()
.map((el) => ({
- pubDate: timezone(parseDate($(el).find('.news_meta').text()), +8),
+ pubDate: timezone(parseDate($(el).find('.news_meta').text()), 8),
link: new URL($(el).find('a').attr('href'), baseUrl).href,
title: $(el).find('a').attr('title'),
}));
diff --git a/lib/routes/ecnu/tyxx.ts b/lib/routes/ecnu/tyxx.ts
index a257b7ada..7b7a16d68 100644
--- a/lib/routes/ecnu/tyxx.ts
+++ b/lib/routes/ecnu/tyxx.ts
@@ -26,7 +26,7 @@ export const route: Route = {
const links = $('ul.news_list.list2 > li')
.toArray()
.map((el) => ({
- pubDate: timezone(parseDate($(el).find('.news_meta').text()), +8),
+ pubDate: timezone(parseDate($(el).find('.news_meta').text()), 8),
link: new URL($(el).find('a').attr('href'), baseUrl).href,
title: $(el).find('a').text(),
}));
diff --git a/lib/routes/ecust/e/news.ts b/lib/routes/ecust/e/news.ts
index 2b982158f..ef4c0bd80 100644
--- a/lib/routes/ecust/e/news.ts
+++ b/lib/routes/ecust/e/news.ts
@@ -45,7 +45,7 @@ async function handler() {
const list = response.data.datas.datas.map((item) => ({
title: item['1'].value,
link: item.url.startsWith('http') ? item.url : `${baseUrl}/engine2/d/${item.id}/${item.engineInstanceId}/0`,
- pubDate: timezone(parseDate(item['6'].value), +8),
+ pubDate: timezone(parseDate(item['6'].value), 8),
}));
const items = await Promise.all(
diff --git a/lib/routes/eeo/kuaixun.ts b/lib/routes/eeo/kuaixun.ts
index 620a3e970..e1e235caa 100644
--- a/lib/routes/eeo/kuaixun.ts
+++ b/lib/routes/eeo/kuaixun.ts
@@ -51,7 +51,7 @@ export const handler = async (ctx: Context): Promise => {
const processedItem: DataItem = {
title,
description,
- pubDate: pubDate ? timezone(parseDate(pubDate), +8) : undefined,
+ pubDate: pubDate ? timezone(parseDate(pubDate), 8) : undefined,
link: linkUrl,
category: categories,
author: authors,
@@ -63,7 +63,7 @@ export const handler = async (ctx: Context): Promise => {
},
image,
banner: image,
- updated: updated ? timezone(parseDate(updated), +8) : undefined,
+ updated: updated ? timezone(parseDate(updated), 8) : undefined,
language,
};
@@ -93,13 +93,13 @@ export const handler = async (ctx: Context): Promise => {
const processedItem: DataItem = {
title,
description,
- pubDate: pubDateStr ? timezone(parseDate(pubDateStr), +8) : item.pubDate,
+ pubDate: pubDateStr ? timezone(parseDate(pubDateStr), 8) : item.pubDate,
author: authors,
content: {
html: description,
text: description,
},
- updated: upDatedStr ? timezone(parseDate(upDatedStr), +8) : item.updated,
+ updated: upDatedStr ? timezone(parseDate(upDatedStr), 8) : item.updated,
language,
};
diff --git a/lib/routes/ehentai/ehapi.ts b/lib/routes/ehentai/ehapi.ts
index add470854..2909546fb 100644
--- a/lib/routes/ehentai/ehapi.ts
+++ b/lib/routes/ehentai/ehapi.ts
@@ -178,10 +178,12 @@ function getBittorrent(cache, bittorrent_page_url) {
function updateBittorrent_url(cache, items) {
// 下种子文件需要动态密码,密码每几次请求就更新一次
for (const item of items) {
- if (item.enclosure_url) {
- item.enclosure_url = item.enclosure_url.replace(/torrent\?p=.*$/, () => `torrent?p=${p}`);
- cache.set(item.bittorrent_page_url, item.enclosure_url);
+ if (!item.enclosure_url) {
+ continue;
}
+
+ item.enclosure_url = item.enclosure_url.replace(/torrent\?p=.*$/, () => `torrent?p=${p}`);
+ cache.set(item.bittorrent_page_url, item.enclosure_url);
}
return items;
}
diff --git a/lib/routes/elasticsearch-cn/index.ts b/lib/routes/elasticsearch-cn/index.ts
index 574c841d9..4860663ec 100644
--- a/lib/routes/elasticsearch-cn/index.ts
+++ b/lib/routes/elasticsearch-cn/index.ts
@@ -58,7 +58,7 @@ async function handler(ctx) {
title: a.text(),
link: a.attr('href'),
author: item.find('.aw-user-name').text(),
- pubDate: timezone(/\d{4}-\d{2}-\d{2} \d{2}:\d{2}/.test(pubDate) ? parseDate(pubDate) : parseRelativeDate(pubDate), +8),
+ pubDate: timezone(/\d{4}-\d{2}-\d{2} \d{2}:\d{2}/.test(pubDate) ? parseDate(pubDate) : parseRelativeDate(pubDate), 8),
};
});
diff --git a/lib/routes/eshukan/academic.ts b/lib/routes/eshukan/academic.ts
index d88be34fc..2fab9c680 100644
--- a/lib/routes/eshukan/academic.ts
+++ b/lib/routes/eshukan/academic.ts
@@ -42,7 +42,7 @@ export const handler = async (ctx) => {
return {
title,
description,
- pubDate: pubDate ? timezone(parseDate(pubDate), +8) : undefined,
+ pubDate: pubDate ? timezone(parseDate(pubDate), 8) : undefined,
link: new URL(a.prop('href'), currentUrl).href,
content: {
html: description,
@@ -69,7 +69,7 @@ export const handler = async (ctx) => {
item.title = title;
item.description = description;
- item.pubDate = pubDate ? timezone(parseDate(pubDate), +8) : item.pubDate;
+ item.pubDate = pubDate ? timezone(parseDate(pubDate), 8) : item.pubDate;
item.author = $$('div.author a').text();
item.content = {
html: description,
diff --git a/lib/routes/everia/article.ts b/lib/routes/everia/article.ts
index eab88176f..25a1d0767 100644
--- a/lib/routes/everia/article.ts
+++ b/lib/routes/everia/article.ts
@@ -2,7 +2,7 @@ import { load } from 'cheerio';
import got from '@/utils/got';
-async function loadArticle(link) {
+export const loadArticle = async (link) => {
const resp = await got(link);
const article = load(resp.body);
@@ -17,6 +17,4 @@ async function loadArticle(link) {
description,
link,
};
-}
-
-export default loadArticle;
+};
diff --git a/lib/routes/everia/category.ts b/lib/routes/everia/category.ts
index f4e6182e4..7b4ffb3ee 100644
--- a/lib/routes/everia/category.ts
+++ b/lib/routes/everia/category.ts
@@ -4,7 +4,7 @@ import type { Route } from '@/types';
import cache from '@/utils/cache';
import got from '@/utils/got';
-import loadArticle from './article';
+import { loadArticle } from './article';
import { SUB_NAME_PREFIX, SUB_URL } from './const';
export const route: Route = {
diff --git a/lib/routes/everia/latest.ts b/lib/routes/everia/latest.ts
index 48c8898ab..f6469292b 100644
--- a/lib/routes/everia/latest.ts
+++ b/lib/routes/everia/latest.ts
@@ -4,7 +4,7 @@ import type { Route } from '@/types';
import cache from '@/utils/cache';
import got from '@/utils/got';
-import loadArticle from './article';
+import { loadArticle } from './article';
import { SUB_NAME_PREFIX, SUB_URL } from './const';
export const route: Route = {
diff --git a/lib/routes/everia/search.ts b/lib/routes/everia/search.ts
index 5e8750031..b58afcc16 100644
--- a/lib/routes/everia/search.ts
+++ b/lib/routes/everia/search.ts
@@ -4,7 +4,7 @@ import type { Route } from '@/types';
import cache from '@/utils/cache';
import got from '@/utils/got';
-import loadArticle from './article';
+import { loadArticle } from './article';
import { SUB_NAME_PREFIX, SUB_URL } from './const';
export const route: Route = {
diff --git a/lib/routes/everia/tag.ts b/lib/routes/everia/tag.ts
index a3d008b5b..b6d92a1da 100644
--- a/lib/routes/everia/tag.ts
+++ b/lib/routes/everia/tag.ts
@@ -4,7 +4,7 @@ import type { Route } from '@/types';
import cache from '@/utils/cache';
import got from '@/utils/got';
-import loadArticle from './article';
+import { loadArticle } from './article';
import { SUB_NAME_PREFIX, SUB_URL } from './const';
export const route: Route = {
diff --git a/lib/routes/f95zone/post.ts b/lib/routes/f95zone/post.ts
index adb27a649..adc79a6b0 100644
--- a/lib/routes/f95zone/post.ts
+++ b/lib/routes/f95zone/post.ts
@@ -48,7 +48,7 @@ Note: This route does not support Radar auto-detection because the post ID is in
const response = await ofetch(link, {
headers: {
referer: baseUrl,
- ...(config.f95zone.cookie ? { cookie: config.f95zone.cookie } : {}),
+ ...(config.f95zone.cookie && { cookie: config.f95zone.cookie }),
},
});
diff --git a/lib/routes/f95zone/thread.ts b/lib/routes/f95zone/thread.ts
index 99446742b..97c3b3963 100644
--- a/lib/routes/f95zone/thread.ts
+++ b/lib/routes/f95zone/thread.ts
@@ -51,7 +51,7 @@ Note: If you want to track a specific post's content changes (e.g., first post w
const headers = {
referer: baseUrl,
- ...(config.f95zone.cookie ? { cookie: config.f95zone.cookie } : {}),
+ ...(config.f95zone.cookie && { cookie: config.f95zone.cookie }),
};
const firstPageResponse = await ofetch(threadLink, { headers });
diff --git a/lib/routes/f95zone/utils.ts b/lib/routes/f95zone/utils.ts
index b2bc99351..8b96600a4 100644
--- a/lib/routes/f95zone/utils.ts
+++ b/lib/routes/f95zone/utils.ts
@@ -54,7 +54,8 @@ export const processContent = (html: string): string => {
return;
}
const allowed = new Set(ALLOWED_ATTRS[el.name] || []);
- for (const attr of Object.keys(el.attribs || {})) {
+ const attrKeys = Object.keys(el.attribs || {});
+ for (const attr of attrKeys) {
if (!allowed.has(attr)) {
$(el).removeAttr(attr);
}
diff --git a/lib/routes/fangchan/list.tsx b/lib/routes/fangchan/list.tsx
index 985149772..a240cd1a5 100644
--- a/lib/routes/fangchan/list.tsx
+++ b/lib/routes/fangchan/list.tsx
@@ -90,14 +90,14 @@ export const handler = async (ctx: Context): Promise => {
let processedItem: DataItem = {
title,
description,
- pubDate: pubDateStr ? timezone(parseDate(pubDateStr), +8) : item.pubDate,
+ pubDate: pubDateStr ? timezone(parseDate(pubDateStr), 8) : item.pubDate,
id: categories,
author: authors,
content: {
html: description,
text: description,
},
- updated: upDatedStr ? timezone(parseDate(upDatedStr), +8) : item.updated,
+ updated: upDatedStr ? timezone(parseDate(upDatedStr), 8) : item.updated,
language,
};
diff --git a/lib/routes/fansly/utils.tsx b/lib/routes/fansly/utils.tsx
index 2a0daa5cc..3a0ca3d63 100644
--- a/lib/routes/fansly/utils.tsx
+++ b/lib/routes/fansly/utils.tsx
@@ -150,7 +150,7 @@ const renderTipGoal = (tipGoalId, tipGoals) => {
export { baseUrl, findAccountById, getAccountByUsername, getTagId, getTagSuggestion, getTimelineByAccountId, icon, parseAttachments, parseDescription, parseMedia, renderMedia, renderPoll, renderTipGoal };
-const FanslyMedia = ({ poster, src }: { poster?: null | { location?: string }; src?: { location?: string } }) => (
+const FanslyMedia = ({ poster, src }: { poster?: { location?: string } | null; src?: { location?: string } }) => (
<>
{poster && src ? (
')
// ruby 標籤(為日文漢字標註讀音)
// ruby tags (for Japanese kanji readings)
- .replaceAll(/\[\[rb:([^>\n\r\u2028\u2029]*)>(.*?)\]\]/g, '$1')
+ .replaceAll(/\[\[rb:([^>\n\r\u{2028}\u{2029}]*)>(.*?)\]\]/gu, '$1')
// 外部連結
// external links
- .replaceAll(/\[\[jumpuri:([^>\n\r\u2028\u2029]*)>(.*?)\]\]/g, '$1')
+ .replaceAll(/\[\[jumpuri:([^>\n\r\u{2028}\u{2029}]*)>(.*?)\]\]/gu, '$1')
// 頁面跳轉,但由於 [newpage] 使用 hr 分隔,沒有頁數,沒必要跳轉,所以只顯示文字
// Page jumps, but since [newpage] uses hr separators, without the page numbers, jumping isn't needed, so just display text
.replaceAll(/\[jump:(\d+)\]/g, 'Jump to page $1')
diff --git a/lib/routes/pku/bbs/hot.ts b/lib/routes/pku/bbs/hot.ts
index c3980de7b..843a2eabc 100644
--- a/lib/routes/pku/bbs/hot.ts
+++ b/lib/routes/pku/bbs/hot.ts
@@ -63,7 +63,7 @@ async function handler() {
description: $('.post-card:first-child .content').html(),
link: url,
guid: url,
- pubDate: timezone(parseDate(date, '发表于YYYY-MM-DD HH:mm:ss'), +8),
+ pubDate: timezone(parseDate(date, '发表于YYYY-MM-DD HH:mm:ss'), 8),
};
} catch {
return {
diff --git a/lib/routes/pts/index.ts b/lib/routes/pts/index.ts
index 55ba5dbd6..fb07c1626 100644
--- a/lib/routes/pts/index.ts
+++ b/lib/routes/pts/index.ts
@@ -52,8 +52,8 @@ async function handler(ctx) {
item.author = content('.reporter-container a')
.toArray()
.map((e) => ({ name: content(e).text() }));
- item.pubDate = timezone(parseDate(content('.article-time .mr-2 time').text()), +8);
- item.updated = timezone(parseDate(content('.article-time span:nth-child(2) time').text()), +8);
+ item.pubDate = timezone(parseDate(content('.article-time .mr-2 time').text()), 8);
+ item.updated = timezone(parseDate(content('.article-time span:nth-child(2) time').text()), 8);
item.category = content('.tag-list')
.first()
.find('.blue-tag')
diff --git a/lib/routes/qianzhan/column.ts b/lib/routes/qianzhan/column.ts
index 2065f2a78..6a7d32e75 100644
--- a/lib/routes/qianzhan/column.ts
+++ b/lib/routes/qianzhan/column.ts
@@ -52,7 +52,7 @@ async function handler(ctx) {
const $ = load(detailResponse.data);
const description = $('#divArtBody').html();
const title = $('#h_title').text();
- const pubDate = timezone(parseDate($('#pubtime_baidu').text().split('• ', 2)[1], 'YYYY-MM-DD HH:mm:ss'), +8);
+ const pubDate = timezone(parseDate($('#pubtime_baidu').text().split('• ', 2)[1], 'YYYY-MM-DD HH:mm:ss'), 8);
const author = $('.bljjxue').text().match(/\S+/)[0];
return {
title,
diff --git a/lib/routes/qianzhan/rank.ts b/lib/routes/qianzhan/rank.ts
index 2aefa3e26..c3a3a528b 100644
--- a/lib/routes/qianzhan/rank.ts
+++ b/lib/routes/qianzhan/rank.ts
@@ -49,7 +49,7 @@ async function handler(ctx) {
const $ = load(detailResponse.data);
const description = $('#divArtBody').html();
const title = $('#h_title').text();
- const pubDate = timezone(parseDate($('#pubtime_baidu').text().split('• ', 2)[1], 'YYYY-MM-DD HH:mm:ss'), +8);
+ const pubDate = timezone(parseDate($('#pubtime_baidu').text().split('• ', 2)[1], 'YYYY-MM-DD HH:mm:ss'), 8);
const author = $('.bljjxue').text().match(/\S+/)[0];
return {
title,
diff --git a/lib/routes/qiche365/recall.ts b/lib/routes/qiche365/recall.ts
index 1d5e88824..51f9364cb 100644
--- a/lib/routes/qiche365/recall.ts
+++ b/lib/routes/qiche365/recall.ts
@@ -54,7 +54,7 @@ async function handler(ctx): Promise {
return {
title: cheerioItem.find('h1').text(),
link: `${baseUrl}${cheerioItem.find('a').attr('href')}`,
- pubDate: timezone(parseDate(cheerioItem.find('h2').html()!.match('(.*?)')![1]), +8),
+ pubDate: timezone(parseDate(cheerioItem.find('h2').html()!.match('(.*?)')![1]), 8),
description: cheerioItem.find('p').text().trim(),
author: cheerioItem.find('h3 span').text(),
image: cheerioItem.find('img').attr('src') && `${baseUrl}${cheerioItem.find('img').attr('src')}`,
diff --git a/lib/routes/qingting/channel.ts b/lib/routes/qingting/channel.ts
index c1afb06fb..be9bc4d30 100644
--- a/lib/routes/qingting/channel.ts
+++ b/lib/routes/qingting/channel.ts
@@ -32,7 +32,7 @@ async function handler(ctx) {
const items = response.data.programs.map((item) => ({
title: item.title,
link: `https://www.qingting.fm/channels/${ctx.req.param('id')}/programs/${item.id}/`,
- pubDate: timezone(parseDate(item.update_time), +8),
+ pubDate: timezone(parseDate(item.update_time), 8),
}));
return {
diff --git a/lib/routes/qingting/podcast.ts b/lib/routes/qingting/podcast.ts
index bbde582e2..98ad908b8 100644
--- a/lib/routes/qingting/podcast.ts
+++ b/lib/routes/qingting/podcast.ts
@@ -90,7 +90,7 @@ async function handler(ctx) {
link,
itunes_item_image: item.cover,
itunes_duration: item.duration,
- pubDate: timezone(parseDate(item.update_time), +8),
+ pubDate: timezone(parseDate(item.update_time), 8),
description: detail.richtext,
};
diff --git a/lib/routes/qm120/news.ts b/lib/routes/qm120/news.ts
index 5fbd5e891..c7a424c4f 100644
--- a/lib/routes/qm120/news.ts
+++ b/lib/routes/qm120/news.ts
@@ -73,7 +73,7 @@ async function handler(ctx) {
const content = load(detailResponse.data);
item.description = content('.neirong_body').html();
- item.pubDate = timezone(parseDate(content('.neirong_head p span').eq(1).text()), +8);
+ item.pubDate = timezone(parseDate(content('.neirong_head p span').eq(1).text()), 8);
return item;
})
diff --git a/lib/routes/qq/cfhd/index.ts b/lib/routes/qq/cfhd/index.ts
index cad4bfeb6..34dd098e8 100644
--- a/lib/routes/qq/cfhd/index.ts
+++ b/lib/routes/qq/cfhd/index.ts
@@ -51,7 +51,7 @@ export const handler = async (ctx) => {
item.title = title;
item.description = description;
- item.pubDate = timezone(parseDate($$('p.news-details-p1').text().trim()), +8);
+ item.pubDate = timezone(parseDate($$('p.news-details-p1').text().trim()), 8);
item.content = {
html: description,
text: $$('div.news-details-cont').text(),
diff --git a/lib/routes/qq/kg/cache.ts b/lib/routes/qq/kg/cache.ts
index 59dce3eb0..617fbe374 100644
--- a/lib/routes/qq/kg/cache.ts
+++ b/lib/routes/qq/kg/cache.ts
@@ -19,7 +19,7 @@ export default {
const itunes_item_image = data.detail.cover;
const enclosure_url = data.detail.playurl;
- ksong_mid = ksong_mid ?? data.detail.ksong_mid;
+ ksong_mid ??= data.detail.ksong_mid;
const ctime = data.detail.ctime;
const comments = data.detail.comments;
diff --git a/lib/routes/qq/lol/news.ts b/lib/routes/qq/lol/news.ts
index d35481f87..e209ad125 100644
--- a/lib/routes/qq/lol/news.ts
+++ b/lib/routes/qq/lol/news.ts
@@ -52,14 +52,14 @@ export const handler = async (ctx: Context): Promise => {
const processedItem: DataItem = {
title,
- pubDate: pubDate ? timezone(parseDate(pubDate), +8) : undefined,
+ pubDate: pubDate ? timezone(parseDate(pubDate), 8) : undefined,
link: linkUrl ? new URL(linkUrl, baseUrl).href : undefined,
author: authors,
guid,
id: guid,
image,
banner: image,
- updated: updated ? timezone(parseDate(updated), +8) : undefined,
+ updated: updated ? timezone(parseDate(updated), 8) : undefined,
language,
};
@@ -106,7 +106,7 @@ export const handler = async (ctx: Context): Promise => {
const processedItem: DataItem = {
title,
description,
- pubDate: pubDate ? timezone(parseDate(pubDate), +8) : undefined,
+ pubDate: pubDate ? timezone(parseDate(pubDate), 8) : undefined,
link: linkUrl ? new URL(linkUrl, baseUrl).href : undefined,
author: authors,
guid,
@@ -117,7 +117,7 @@ export const handler = async (ctx: Context): Promise => {
},
image,
banner: image,
- updated: updated ? timezone(parseDate(updated), +8) : undefined,
+ updated: updated ? timezone(parseDate(updated), 8) : undefined,
language,
};
diff --git a/lib/routes/qqorw/index.ts b/lib/routes/qqorw/index.ts
index 9d0696dff..21ab2f82c 100644
--- a/lib/routes/qqorw/index.ts
+++ b/lib/routes/qqorw/index.ts
@@ -59,7 +59,7 @@ async function handler(ctx) {
.find('a.label')
.toArray()
.map((c) => $(c).text()),
- pubDate: timezone(parseDate(item.find('p.auth-span span.muted').first().text().trim()), +8),
+ pubDate: timezone(parseDate(item.find('p.auth-span span.muted').first().text().trim()), 8),
upvotes: item.find('span.count').text() ? Number(item.find('span.count').text()) : 0,
};
});
@@ -79,7 +79,7 @@ async function handler(ctx) {
item.category = content('#mute-category')
.toArray()
.map((c) => content(c).text().trim());
- item.pubDate = item.pubDate ?? parseDate(content('i.fa-clock-o').parent().text().trim());
+ item.pubDate ??= parseDate(content('i.fa-clock-o').parent().text().trim());
item.upvotes = content('#Addlike span.count').text() ? Number(content('#Addlike span.count').text()) : item.upvotes;
return item;
diff --git a/lib/routes/quicker/qa.ts b/lib/routes/quicker/qa.ts
index 858f0a559..796ac38a7 100644
--- a/lib/routes/quicker/qa.ts
+++ b/lib/routes/quicker/qa.ts
@@ -89,7 +89,7 @@ async function handler(ctx) {
item.description = content('.topic-body').html();
item.author = content('.user-link').first().text();
- item.pubDate = timezone(/-/.test(pubDate) ? parseDate(pubDate) : parseRelativeDate(pubDate), +8);
+ item.pubDate = timezone(/-/.test(pubDate) ? parseDate(pubDate) : parseRelativeDate(pubDate), 8);
return item;
})
diff --git a/lib/routes/quicker/share.ts b/lib/routes/quicker/share.ts
index db06b3ace..cfc78802c 100644
--- a/lib/routes/quicker/share.ts
+++ b/lib/routes/quicker/share.ts
@@ -78,7 +78,7 @@ async function handler(ctx) {
item.author = content('.user-link').first().text();
item.description = content('div[data-info="动作信息"]').html() ?? content('#app').html() ?? content('.row').eq(1).html();
- item.pubDate = timezone(/-/.test(pubDate) ? parseDate(pubDate) : parseRelativeDate(pubDate), +8);
+ item.pubDate = timezone(/-/.test(pubDate) ? parseDate(pubDate) : parseRelativeDate(pubDate), 8);
return item;
})
diff --git a/lib/routes/quicker/user.ts b/lib/routes/quicker/user.ts
index d9814894a..4d4ffea56 100644
--- a/lib/routes/quicker/user.ts
+++ b/lib/routes/quicker/user.ts
@@ -70,7 +70,7 @@ async function handler(ctx) {
item.author = content('.user-link').first().text();
item.description = content('div[data-info="动作信息"]').html() ?? content('#app').html() ?? content('.row').eq(1).html();
- item.pubDate = timezone(/-/.test(pubDate) ? parseDate(pubDate) : parseRelativeDate(pubDate), +8);
+ item.pubDate = timezone(/-/.test(pubDate) ? parseDate(pubDate) : parseRelativeDate(pubDate), 8);
return item;
})
diff --git a/lib/routes/qztc/home/index.ts b/lib/routes/qztc/home/index.ts
index 241f73667..641b822de 100644
--- a/lib/routes/qztc/home/index.ts
+++ b/lib/routes/qztc/home/index.ts
@@ -60,7 +60,7 @@ async function handler(ctx) {
} else if (!link.startsWith('http')) {
link = rootUrl.slice(0, -1) + link;
}
- const pubDate = timezone(parseDate(cheerioItem.find('.news_meta').text()), +8);
+ const pubDate = timezone(parseDate(cheerioItem.find('.news_meta').text()), 8);
return {
title,
diff --git a/lib/routes/qztc/jwc/index.ts b/lib/routes/qztc/jwc/index.ts
index 4101aabb7..3a73592d4 100644
--- a/lib/routes/qztc/jwc/index.ts
+++ b/lib/routes/qztc/jwc/index.ts
@@ -70,7 +70,7 @@ async function handler(ctx) {
} else if (!link.startsWith('http')) {
link = rootUrl.slice(0, -1) + link;
}
- const pubDate = timezone(parseDate(cheerioItem.find('.news_meta').text()), +8);
+ const pubDate = timezone(parseDate(cheerioItem.find('.news_meta').text()), 8);
return {
title,
diff --git a/lib/routes/qztc/sjxy/index.ts b/lib/routes/qztc/sjxy/index.ts
index 439483247..786844627 100644
--- a/lib/routes/qztc/sjxy/index.ts
+++ b/lib/routes/qztc/sjxy/index.ts
@@ -70,7 +70,7 @@ async function handler(ctx) {
} else if (!link.startsWith('http')) {
link = rootUrl.slice(0, -1) + link;
}
- const pubDate = timezone(parseDate(cheerioItem.find('.news_meta').text()), +8);
+ const pubDate = timezone(parseDate(cheerioItem.find('.news_meta').text()), 8);
return {
title,
diff --git a/lib/routes/radio-canada/latest.ts b/lib/routes/radio-canada/latest.ts
index 71c7bfc65..29511b47a 100644
--- a/lib/routes/radio-canada/latest.ts
+++ b/lib/routes/radio-canada/latest.ts
@@ -82,7 +82,8 @@ const parseDescriptionFromState = (rcState) => {
const primer = news?.data?.newsStory?.primer?.replaceAll(String.raw`\n`, '') ?? '';
const body = news?.data?.newsStory?.body?.html?.replaceAll(String.raw`\n`, '') ?? '';
let bodyWithImg = body;
- for (const [index, attachment] of (news?.data?.newsStory?.body?.attachments ?? []).entries()) {
+ const attachments = news?.data?.newsStory?.body?.attachments ?? [];
+ for (const [index, attachment] of attachments.entries()) {
const placeholder = ``;
const picture = attachment?.picture;
const imageUrl = picture?.pattern ? picture?.pattern.replace('/q_auto,w_{width}', '').replace('{ratio}', () => attachment?.dimensionRatio ?? '16x9') : '';
diff --git a/lib/routes/radio/album.ts b/lib/routes/radio/album.ts
index 51a258360..a546c5239 100644
--- a/lib/routes/radio/album.ts
+++ b/lib/routes/radio/album.ts
@@ -83,7 +83,7 @@ async function handler(ctx) {
title: item.name,
link: `${rootUrl}/share/albumPlay?correlateId=${item.id}&columnId=${id}`,
description: renderDescription({ enclosure_url, enclosure_type }),
- pubDate: timezone(parseDate(item.createTime), +8),
+ pubDate: timezone(parseDate(item.createTime), 8),
enclosure_url,
enclosure_type,
enclosure_length: item.fileSize,
diff --git a/lib/routes/reuters/common.tsx b/lib/routes/reuters/common.tsx
index c4be6f9ff..70dea8e8d 100644
--- a/lib/routes/reuters/common.tsx
+++ b/lib/routes/reuters/common.tsx
@@ -231,13 +231,11 @@ async function handler(ctx) {
size: limit,
section_id,
website: 'reuters',
- ...(useSophi
- ? {
- fetch_type: 'sophi',
- sophi_page: '*',
- sophi_widget: 'topic',
- }
- : {}),
+ ...(useSophi && {
+ fetch_type: 'sophi',
+ sophi_page: '*',
+ sophi_widget: 'topic',
+ }),
}),
},
headers: browserHeaders,
diff --git a/lib/routes/right/forum.ts b/lib/routes/right/forum.ts
index 2bc77169e..e216bb4d6 100644
--- a/lib/routes/right/forum.ts
+++ b/lib/routes/right/forum.ts
@@ -68,7 +68,7 @@ async function handler(ctx) {
item.author = content('.authi').first().text();
item.description = content('.t_f').first().html();
- item.pubDate = timezone(parseDate(content('.authi em').first().text().replace('发表于 ', '')), +8);
+ item.pubDate = timezone(parseDate(content('.authi em').first().text().replace('发表于 ', '')), 8);
item.category = content('.ptg a')
.toArray()
.map((a) => content(a).text());
diff --git a/lib/routes/rsc/journal.tsx b/lib/routes/rsc/journal.tsx
index 475f31d60..670686ebd 100644
--- a/lib/routes/rsc/journal.tsx
+++ b/lib/routes/rsc/journal.tsx
@@ -85,7 +85,7 @@ async function handler(ctx) {
author: authors,
category: [item.find('span.capsule__context').text().trim(), ...authors.split(/,\s|and\s/), isOpenAccess || isManuscript],
guid: `rsc-${doi}`,
- pubDate: timezone(parseDate(item.find('div.text--small span.block').text().split(/on\s/).pop(), 'DD MMM YYYY'), +1),
+ pubDate: timezone(parseDate(item.find('div.text--small span.block').text().split(/on\s/).pop(), 'DD MMM YYYY'), 1),
enclosure_url: enclosureUrl,
enclosure_type: enclosureUrl ? 'application/pdf' : undefined,
doi,
@@ -105,7 +105,7 @@ async function handler(ctx) {
item.title = content('meta[name="DC.title"]').prop('content');
item.description = content('#wrapper, article.article-control').html();
- item.pubDate = timezone(parseDate(content('meta[name="citation_online_date"]').prop('content'), 'YYYY/MM/DD'), +1);
+ item.pubDate = timezone(parseDate(content('meta[name="citation_online_date"]').prop('content'), 'YYYY/MM/DD'), 1);
item.enclosure_url = content('meta[name="citation_pdf_url"]').prop('content');
item.enclosure_type = item.enclosure_url ? 'application/pdf' : undefined;
item.doi = content('meta[name="DC.Identifier"]').prop('content');
diff --git a/lib/routes/ruancan/category.ts b/lib/routes/ruancan/category.ts
index a1111e395..dbee93f04 100644
--- a/lib/routes/ruancan/category.ts
+++ b/lib/routes/ruancan/category.ts
@@ -1,6 +1,6 @@
import type { Route } from '@/types';
-import fetchFeed from './utils';
+import { fetchFeed } from './utils';
export const route: Route = {
path: '/category/:category?',
diff --git a/lib/routes/ruancan/index.ts b/lib/routes/ruancan/index.ts
index 5e6a66ad2..9647f0a77 100644
--- a/lib/routes/ruancan/index.ts
+++ b/lib/routes/ruancan/index.ts
@@ -1,6 +1,6 @@
import type { Route } from '@/types';
-import fetchFeed from './utils';
+import { fetchFeed } from './utils';
export const route: Route = {
path: '/',
diff --git a/lib/routes/ruancan/search.ts b/lib/routes/ruancan/search.ts
index ad067e54f..7a5ffe4d7 100644
--- a/lib/routes/ruancan/search.ts
+++ b/lib/routes/ruancan/search.ts
@@ -1,6 +1,6 @@
import type { Route } from '@/types';
-import fetchFeed from './utils';
+import { fetchFeed } from './utils';
export const route: Route = {
path: '/search/:keyword?',
diff --git a/lib/routes/ruancan/user.ts b/lib/routes/ruancan/user.ts
index df2dd2c8f..6ed3d3f08 100644
--- a/lib/routes/ruancan/user.ts
+++ b/lib/routes/ruancan/user.ts
@@ -1,6 +1,6 @@
import type { Route } from '@/types';
-import fetchFeed from './utils';
+import { fetchFeed } from './utils';
export const route: Route = {
path: '/user/:id',
diff --git a/lib/routes/ruancan/utils.ts b/lib/routes/ruancan/utils.ts
index 9c8c335d2..27dc82ff8 100644
--- a/lib/routes/ruancan/utils.ts
+++ b/lib/routes/ruancan/utils.ts
@@ -4,7 +4,7 @@ import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
-const fetchFeed = async (ctx, currentUrl) => {
+export const fetchFeed = async (ctx, currentUrl) => {
const rootUrl = 'https://www.ruancan.com';
currentUrl = `${rootUrl}${currentUrl}`;
@@ -66,4 +66,3 @@ const fetchFeed = async (ctx, currentUrl) => {
item: items,
};
};
-export default fetchFeed;
diff --git a/lib/routes/ruc/ai.ts b/lib/routes/ruc/ai.ts
index b892f3f8f..dc4d4eb1e 100644
--- a/lib/routes/ruc/ai.ts
+++ b/lib/routes/ruc/ai.ts
@@ -54,7 +54,7 @@ export const route: Route = {
item.title = title;
const titleDiv = $('div.tit');
const date = titleDiv.find('span').first().text();
- item.pubDate = timezone(parseDate(/\d+-\d+-\d+/.exec(date)[0]), +8);
+ item.pubDate = timezone(parseDate(/\d+-\d+-\d+/.exec(date)[0]), 8);
const frame = $('div.fr');
item.description = frame
.children()
diff --git a/lib/routes/rustcc/jobs.ts b/lib/routes/rustcc/jobs.ts
index d8dedc1f0..d38040fdc 100644
--- a/lib/routes/rustcc/jobs.ts
+++ b/lib/routes/rustcc/jobs.ts
@@ -60,6 +60,6 @@ function getFeedItem(item) {
title: title.text(),
link: `${base_url}${title.attr('href')}`,
description: $('.info .tags').text(),
- pubDate: timezone(parseDate($('.info .timestamp').text(), 'YYYY-MM-DD hh:mm'), +8),
+ pubDate: timezone(parseDate($('.info .timestamp').text(), 'YYYY-MM-DD hh:mm'), 8),
};
}
diff --git a/lib/routes/rustcc/news.ts b/lib/routes/rustcc/news.ts
index c67cd925a..8f508d133 100644
--- a/lib/routes/rustcc/news.ts
+++ b/lib/routes/rustcc/news.ts
@@ -51,6 +51,6 @@ function getFeedItem(item) {
title: title.text(),
link: `${baseUrl}${title.attr('href')}`,
description: $('.info .tags').text(),
- pubDate: timezone(parseDate($('.info .timestamp').text(), 'YYYY-MM-DD hh:mm'), +8),
+ pubDate: timezone(parseDate($('.info .timestamp').text(), 'YYYY-MM-DD hh:mm'), 8),
};
}
diff --git a/lib/routes/sakurazaka46/blog.ts b/lib/routes/sakurazaka46/blog.ts
index 02a792e98..186940281 100644
--- a/lib/routes/sakurazaka46/blog.ts
+++ b/lib/routes/sakurazaka46/blog.ts
@@ -100,7 +100,7 @@ async function handler(ctx) {
const content = load(detailResponse.data);
item.description = content('.box-article').html();
- item.pubDate = timezone(parseDate(content('.blog-foot .date').text()), +9);
+ item.pubDate = timezone(parseDate(content('.blog-foot .date').text()), 9);
return item;
})
diff --git a/lib/routes/samd/news.ts b/lib/routes/samd/news.ts
index a05398552..1d6eb97e5 100644
--- a/lib/routes/samd/news.ts
+++ b/lib/routes/samd/news.ts
@@ -56,7 +56,7 @@ export const route: Route = {
const content = $('.content');
item.author = content.find('.author span').text();
- item.pubDate = timezone(parseDate(content.find('.time').text(), '发布时间:YYYY-MM-DD HH:mm:ss'), +8);
+ item.pubDate = timezone(parseDate(content.find('.time').text(), '发布时间:YYYY-MM-DD HH:mm:ss'), 8);
content.children('.titles').remove();
content.children('.auxi').remove();
diff --git a/lib/routes/saraba1st/digest.tsx b/lib/routes/saraba1st/digest.tsx
index e0f368cf5..a61fb76dd 100644
--- a/lib/routes/saraba1st/digest.tsx
+++ b/lib/routes/saraba1st/digest.tsx
@@ -51,7 +51,7 @@ async function handler(ctx) {
title: `${title}:${floor}`,
link: new URL(floorUrl, `${host}/2b/`).href,
author: each.find('td.by cite').text(),
- pubDate: timezone(parseDate(each.find('td.by em').first().text()), +8),
+ pubDate: timezone(parseDate(each.find('td.by em').first().text()), 8),
};
});
diff --git a/lib/routes/saraba1st/thread.ts b/lib/routes/saraba1st/thread.ts
index 860020316..aef3238bf 100644
--- a/lib/routes/saraba1st/thread.ts
+++ b/lib/routes/saraba1st/thread.ts
@@ -59,14 +59,16 @@ async function handler(ctx) {
const contentHtml = $(each.find('td.t_f'));
const imgsHtml = contentHtml.find('img');
for (const element of imgsHtml) {
- if (element.attribs.src === staticUrl.href) {
- element.attribs.src = element.attribs.file;
- const imgHtml = $(element);
- imgHtml.removeAttr('zoomfile');
- imgHtml.removeAttr('file');
- imgHtml.removeAttr('onmouseover');
- imgHtml.removeAttr('onclick');
+ if (element.attribs.src !== staticUrl.href) {
+ continue;
}
+
+ element.attribs.src = element.attribs.file;
+ const imgHtml = $(element);
+ imgHtml.removeAttr('zoomfile');
+ imgHtml.removeAttr('file');
+ imgHtml.removeAttr('onmouseover');
+ imgHtml.removeAttr('onclick');
}
contentHtml.find('div.aimg_tip').remove();
return {
@@ -74,7 +76,7 @@ async function handler(ctx) {
link: new URL(floorUrl, `${host}/2b/`).href,
description: contentHtml.html(),
author: each.find('.authi .xw1').text(),
- pubDate: timezone(parseDate(each.find('.authi em').text()), +8),
+ pubDate: timezone(parseDate(each.find('.authi em').text()), 8),
};
});
diff --git a/lib/routes/sciencenet/blog.ts b/lib/routes/sciencenet/blog.ts
index a7457a336..61a3af576 100644
--- a/lib/routes/sciencenet/blog.ts
+++ b/lib/routes/sciencenet/blog.ts
@@ -84,7 +84,7 @@ async function handler(ctx) {
item.author = content('.xs2').text();
item.description = content('#blog_article').html();
- item.pubDate = timezone(parseDate(content('.xg1').eq(5).text()), +8);
+ item.pubDate = timezone(parseDate(content('.xg1').eq(5).text()), 8);
return item;
})
diff --git a/lib/routes/sciencenet/user.ts b/lib/routes/sciencenet/user.ts
index 5a64c3c88..fc26e5ae0 100644
--- a/lib/routes/sciencenet/user.ts
+++ b/lib/routes/sciencenet/user.ts
@@ -78,7 +78,7 @@ async function handler(ctx) {
item.author = content('.xs2').text();
item.description = content('#blog_article').html();
- item.pubDate = timezone(parseDate(content('.xg1').eq(5).text()), +8);
+ item.pubDate = timezone(parseDate(content('.xg1').eq(5).text()), 8);
return item;
})
diff --git a/lib/routes/scientificamerican/podcast.ts b/lib/routes/scientificamerican/podcast.ts
index 8985a377a..348b00d8d 100644
--- a/lib/routes/scientificamerican/podcast.ts
+++ b/lib/routes/scientificamerican/podcast.ts
@@ -55,7 +55,7 @@ export const handler = async (ctx: Context): Promise => {
let processedItem: DataItem = {
title,
description,
- pubDate: pubDate ? timezone(parseDate(pubDate), +8) : undefined,
+ pubDate: pubDate ? timezone(parseDate(pubDate), 8) : undefined,
link: linkUrl ? new URL(linkUrl, baseUrl).href : undefined,
category: categories,
author: authors,
@@ -68,7 +68,7 @@ export const handler = async (ctx: Context): Promise => {
},
image,
banner: image,
- updated: updated ? timezone(parseDate(updated), +8) : undefined,
+ updated: updated ? timezone(parseDate(updated), 8) : undefined,
language,
};
@@ -138,7 +138,7 @@ export const handler = async (ctx: Context): Promise => {
let processedItem: DataItem = {
title,
description,
- pubDate: pubDate ? timezone(parseDate(pubDate), +8) : undefined,
+ pubDate: pubDate ? timezone(parseDate(pubDate), 8) : undefined,
category: categories,
author: authors,
doi: articleData.article_doi,
@@ -150,7 +150,7 @@ export const handler = async (ctx: Context): Promise => {
},
image,
banner: image,
- updated: updated ? timezone(parseDate(updated), +8) : undefined,
+ updated: updated ? timezone(parseDate(updated), 8) : undefined,
language,
};
diff --git a/lib/routes/scitechvista/index.tsx b/lib/routes/scitechvista/index.tsx
index 392806978..970b181f0 100644
--- a/lib/routes/scitechvista/index.tsx
+++ b/lib/routes/scitechvista/index.tsx
@@ -69,7 +69,7 @@ async function handler(): Promise {
const title = node.find('div.kf-title').text().trim();
const dateText = node.find('div.kf-date > span').text().trim();
- const pubDate = dateText ? timezone(parseRocDate(dateText), +8) : undefined;
+ const pubDate = dateText ? timezone(parseRocDate(dateText), 8) : undefined;
const imagePath = node.find('img').attr('src');
const image = imagePath ? new URL(imagePath, baseUrl).href : undefined;
diff --git a/lib/routes/scnu/physics-school-announcements-and-news.ts b/lib/routes/scnu/physics-school-announcements-and-news.ts
index aba172628..db362591f 100644
--- a/lib/routes/scnu/physics-school-announcements-and-news.ts
+++ b/lib/routes/scnu/physics-school-announcements-and-news.ts
@@ -19,7 +19,7 @@ const getAritlces = async (category, url, cache) => {
return {
title: a.text(),
link,
- pubDate: timezone(parseDate(item.find('span.time').text()), +8),
+ pubDate: timezone(parseDate(item.find('span.time').text()), 8),
category,
};
})
diff --git a/lib/routes/sctv/programme.tsx b/lib/routes/sctv/programme.tsx
index bf8c8e4a8..27ffa096a 100644
--- a/lib/routes/sctv/programme.tsx
+++ b/lib/routes/sctv/programme.tsx
@@ -112,7 +112,7 @@ async function handler(ctx) {
guid: item.id,
title: item.programmeTitle,
link: item.programmeUrl,
- pubDate: timezone(parseDate(item.pubTime), +8),
+ pubDate: timezone(parseDate(item.pubTime), 8),
description: renderToString(
@@ -138,11 +138,13 @@ async function handler(ctx) {
let name, cover;
for (const p of response.data.data.programme_official) {
- if (p.programmeId === id) {
- name = p.programmeName;
- cover = p.programmeCover;
- break;
+ if (p.programmeId !== id) {
+ continue;
}
+
+ name = p.programmeName;
+ cover = p.programmeCover;
+ break;
}
return {
diff --git a/lib/routes/sdo/ff14risingstones/types/party.ts b/lib/routes/sdo/ff14risingstones/types/party.ts
index 07c701a22..78ef52544 100644
--- a/lib/routes/sdo/ff14risingstones/types/party.ts
+++ b/lib/routes/sdo/ff14risingstones/types/party.ts
@@ -34,11 +34,11 @@ export interface DutiesParty extends BaseParty {
progress: string;
strategy: string;
team_composition: string;
- team_position: null | {
+ team_position: {
A: TeamPosition;
B: TeamPosition;
C: TeamPosition;
- };
+ } | null;
}
export interface DutiesPartyDetail extends DutiesParty {
diff --git a/lib/routes/sdo/ff14risingstones/user-resently.ts b/lib/routes/sdo/ff14risingstones/user-resently.ts
index df453df2e..f53c3888f 100644
--- a/lib/routes/sdo/ff14risingstones/user-resently.ts
+++ b/lib/routes/sdo/ff14risingstones/user-resently.ts
@@ -33,7 +33,7 @@ async function handler(ctx: Context) {
image: userInfo.avatar,
item: resently.map((i) => ({
title: `${i.event_type} - ${i.detail}`,
- pubDate: timezone(parseDate(i.log_time), +8),
+ pubDate: timezone(parseDate(i.log_time), 8),
guid: `sdo/ff14risingstones/resently:${uid}-${i.detail}`,
})),
} as Data;
diff --git a/lib/routes/sdo/ff14risingstones/utils.tsx b/lib/routes/sdo/ff14risingstones/utils.tsx
index 8839437e1..ced12387c 100644
--- a/lib/routes/sdo/ff14risingstones/utils.tsx
+++ b/lib/routes/sdo/ff14risingstones/utils.tsx
@@ -144,8 +144,8 @@ export async function generatePostFeeds(posts: UserPost[]) {
title: `[${post.part_name}] ${post.title}`,
link: `${INDEX_URL}#/post/detail/${post.posts_id}`,
description: detail?.contentInfo.content,
- pubDate: timezone(parseDate(post.created_at), +8),
- updated: detail?.updated_at ? timezone(parseDate(detail.updated_at), +8) : undefined,
+ pubDate: timezone(parseDate(post.created_at), 8),
+ updated: detail?.updated_at ? timezone(parseDate(detail.updated_at), 8) : undefined,
guid: `sdo/ff14risingstones/posts:${post.posts_id}`,
author: `${post.character_name}@${post.group_name}`,
} as DataItem;
@@ -304,7 +304,7 @@ export async function generateDynamicFeeds(dynamics: UserDynamic[]) {
return {
title,
link,
- pubDate: timezone(parseDate(dynamic.created_at), +8),
+ pubDate: timezone(parseDate(dynamic.created_at), 8),
guid: `sdo/ff14risingstones/dynamics:${dynamic.id}`,
author: `${dynamic.character_name}@${dynamic.group_name}`,
description,
diff --git a/lib/routes/sdu/epe.ts b/lib/routes/sdu/epe.ts
index 188bbcdac..7237ef9e9 100644
--- a/lib/routes/sdu/epe.ts
+++ b/lib/routes/sdu/epe.ts
@@ -63,7 +63,7 @@ async function handler(ctx) {
item.title = $('#show_title').text().trim();
item.author = info[1].replace('编辑:', '') || '山东大学能源与动力工程学院';
item.description = $('#show_content').html();
- item.pubDate = timezone(parseDate(date), +8);
+ item.pubDate = timezone(parseDate(date), 8);
return item;
});
diff --git a/lib/routes/sdu/extractor/index.ts b/lib/routes/sdu/extractor/index.ts
index 55edee95b..63604ab7f 100644
--- a/lib/routes/sdu/extractor/index.ts
+++ b/lib/routes/sdu/extractor/index.ts
@@ -1,7 +1,7 @@
-import sdrj from './sdrj';
-import view from './view';
-import jwc from './wh/jwc';
-import news from './wh/news';
+import { sdrj } from './sdrj';
+import { view } from './view';
+import { jwc } from './wh/jwc';
+import { news } from './wh/news';
const index = (link) => {
if (link.startsWith('https://xinwen.wh.sdu.edu.cn/')) {
@@ -18,4 +18,5 @@ const index = (link) => {
}
return {};
};
+// TODO: missing route export
export default index;
diff --git a/lib/routes/sdu/extractor/sdrj.ts b/lib/routes/sdu/extractor/sdrj.ts
index 397f92c3b..288fe40f4 100644
--- a/lib/routes/sdu/extractor/sdrj.ts
+++ b/lib/routes/sdu/extractor/sdrj.ts
@@ -5,7 +5,7 @@ import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
-const sdrj = (link) =>
+export const sdrj = (link) =>
cache.tryGet(link, async () => {
let content, author, exactDate;
try {
@@ -15,10 +15,9 @@ const sdrj = (link) =>
author = $("form[name='_newscontent_fromname'] > h1").text();
const exactDateLine = $("form[name='_newscontent_fromname'] > p.info").text().trim();
const exactDateText = exactDateLine.match(/^发布时间:(?\d+\/\d+\/\d+\s\d{2}:\d{2}:\d{2})/).groups.date;
- exactDate = timezone(parseDate(exactDateText, 'YYYY/MM/DD HH:mm:ss'), +8);
+ exactDate = timezone(parseDate(exactDateText, 'YYYY/MM/DD HH:mm:ss'), 8);
return { description: content, author, exactDate };
} catch {
return { description: content, author, exactDate };
}
});
-export default sdrj;
diff --git a/lib/routes/sdu/extractor/view.ts b/lib/routes/sdu/extractor/view.ts
index 9f62f3d26..6fa776813 100644
--- a/lib/routes/sdu/extractor/view.ts
+++ b/lib/routes/sdu/extractor/view.ts
@@ -5,7 +5,7 @@ import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
-const view = (link) =>
+export const view = (link) =>
cache.tryGet(link, async () => {
let content, author, exactDate;
try {
@@ -15,10 +15,9 @@ const view = (link) =>
author = $("form[name='_newscontent_fromname'] > div > p:last-of-type").text();
const exactDateLine = $('.news_tit > p:last-child').text();
const exactDateText = exactDateLine.match(/^发布日期:(?\d+年\d+月\d+日\s\d{2}:\d{2})/).groups.date;
- exactDate = timezone(parseDate(exactDateText, 'YYYY年MM月DD日 HH:mm'), +8);
+ exactDate = timezone(parseDate(exactDateText, 'YYYY年MM月DD日 HH:mm'), 8);
return { description: content, author, exactDate };
} catch {
return { description: content, author, exactDate };
}
});
-export default view;
diff --git a/lib/routes/sdu/extractor/wh/jwc.ts b/lib/routes/sdu/extractor/wh/jwc.ts
index 22755b8a7..5fe9cfe47 100644
--- a/lib/routes/sdu/extractor/wh/jwc.ts
+++ b/lib/routes/sdu/extractor/wh/jwc.ts
@@ -5,7 +5,7 @@ import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
-const jwc = (link) =>
+export const jwc = (link) =>
cache.tryGet(link, async () => {
let content, exactDate;
try {
@@ -18,10 +18,9 @@ const jwc = (link) =>
exactDateElement.remove();
content = form.html();
const exactDateText = exactDateStr.match(/^创建时间:(?\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2})/).groups.date;
- exactDate = timezone(parseDate(exactDateText, 'YYYY-MM-DD HH:mm:ss'), +8);
+ exactDate = timezone(parseDate(exactDateText, 'YYYY-MM-DD HH:mm:ss'), 8);
return { description: content, exactDate };
} catch {
return { description: content, exactDate };
}
});
-export default jwc;
diff --git a/lib/routes/sdu/extractor/wh/news.ts b/lib/routes/sdu/extractor/wh/news.ts
index 88d430fae..b78e64324 100644
--- a/lib/routes/sdu/extractor/wh/news.ts
+++ b/lib/routes/sdu/extractor/wh/news.ts
@@ -5,7 +5,7 @@ import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
-const news = (link) =>
+export const news = (link) =>
cache.tryGet(link, async () => {
let content, author, exactDate;
try {
@@ -15,10 +15,9 @@ const news = (link) =>
author = $('#source').text();
const exactDateLine = $('.news_tit > p:last-child').text();
const exactDateText = exactDateLine.match(/^发布日期:(?\d+年\d+月\d+日\s\d{2}:\d{2})/).groups.date;
- exactDate = timezone(parseDate(exactDateText, 'YYYY年MM月DD日 HH:mm'), +8);
+ exactDate = timezone(parseDate(exactDateText, 'YYYY年MM月DD日 HH:mm'), 8);
return { description: content, author, exactDate };
} catch {
return { description: content, author, exactDate };
}
});
-export default news;
diff --git a/lib/routes/sdu/mech.ts b/lib/routes/sdu/mech.ts
index 70bd1fb7b..1dc737e1d 100644
--- a/lib/routes/sdu/mech.ts
+++ b/lib/routes/sdu/mech.ts
@@ -67,7 +67,7 @@ async function handler(ctx) {
item.author = info[1].replace('作者:', '') || '山东大学机械工程学院';
$('#show_title, #show_info').remove();
item.description = $('form[name=_newscontent_fromname] div').html();
- item.pubDate = timezone(parseDate(date), +8);
+ item.pubDate = timezone(parseDate(date), 8);
return item;
});
diff --git a/lib/routes/sdu/wh/jwc.ts b/lib/routes/sdu/wh/jwc.ts
index 126470fd6..29ff04d40 100644
--- a/lib/routes/sdu/wh/jwc.ts
+++ b/lib/routes/sdu/wh/jwc.ts
@@ -48,7 +48,7 @@ async function handler(ctx) {
const title = item.text();
const { description, author: exactAuthor, exactDate } = await cache.tryGet(link, () => extractor(link));
const author = exactAuthor ?? '教务处';
- const pubDate = exactDate ?? timezone(parseDate(dateText.slice(1, -1), 'YYYY-MM-DD'), +8);
+ const pubDate = exactDate ?? timezone(parseDate(dateText.slice(1, -1), 'YYYY-MM-DD'), 8);
return {
title,
link,
diff --git a/lib/routes/sega/pjsekai.ts b/lib/routes/sega/pjsekai.ts
index 01abdc65f..85e3844c9 100644
--- a/lib/routes/sega/pjsekai.ts
+++ b/lib/routes/sega/pjsekai.ts
@@ -60,7 +60,7 @@ async function handler() {
const item = {
title: post.title,
link,
- pubDate: timezone(new Date(post.startAt), +8), // +8时区
+ pubDate: timezone(new Date(post.startAt), 8), // +8时区
description,
category: post.informationTag, // event,gacha,music,bug,information
guid,
diff --git a/lib/routes/setn/index.ts b/lib/routes/setn/index.ts
index e89573d4b..9c0f72506 100644
--- a/lib/routes/setn/index.ts
+++ b/lib/routes/setn/index.ts
@@ -132,7 +132,7 @@ async function handler(ctx) {
item.title = content('h1').text();
item.author = head?.author?.name || content('meta[name="author"]').attr('content');
item.category = [content('meta[property="article:section"]').attr('content'), ...content('meta[name="news_keywords"]').attr('content').split(',')];
- item.pubDate = timezone(parseDate(content('meta[property="article:published_time"]').attr('content')), +8);
+ item.pubDate = timezone(parseDate(content('meta[property="article:published_time"]').attr('content')), 8);
item.description = content('article, .content-p').html();
return item;
diff --git a/lib/routes/sfacg/novel-chapter.ts b/lib/routes/sfacg/novel-chapter.ts
index 103c76de5..7514ca57d 100644
--- a/lib/routes/sfacg/novel-chapter.ts
+++ b/lib/routes/sfacg/novel-chapter.ts
@@ -57,7 +57,7 @@ async function handler(ctx) {
item.description = $('div.article-content').html();
const rawDate = $('div.article-desc span').eq(1).text();
- item.pubDate = timezone(parseDate(rawDate.replace('更新时间:', '')), +8);
+ item.pubDate = timezone(parseDate(rawDate.replace('更新时间:', '')), 8);
return item;
})
diff --git a/lib/routes/shcstheatre/programs.tsx b/lib/routes/shcstheatre/programs.tsx
index 830ae60be..7ee20b9b5 100644
--- a/lib/routes/shcstheatre/programs.tsx
+++ b/lib/routes/shcstheatre/programs.tsx
@@ -143,7 +143,7 @@ async function handler() {
title: data.SCS_WEB_BRIEFNAME,
link: link.href,
description: renderDescription(data),
- pubDate: timezone(parseDate(data.SJ_DATE_PC), +8),
+ pubDate: timezone(parseDate(data.SJ_DATE_PC), 8),
};
});
})
diff --git a/lib/routes/shmeea/index.ts b/lib/routes/shmeea/index.ts
index 5a8df7a36..79304183a 100644
--- a/lib/routes/shmeea/index.ts
+++ b/lib/routes/shmeea/index.ts
@@ -66,7 +66,7 @@ async function handler(ctx) {
const pbTimeText = $('#ivs_title .PBtime').text().trim();
item.description = description;
- item.pubDate = pbTimeText ? timezone(parseDate(pbTimeText, 'YYYY-MM-DD HH:mm:ss'), +8) : item.pubDate;
+ item.pubDate = pbTimeText ? timezone(parseDate(pbTimeText, 'YYYY-MM-DD HH:mm:ss'), 8) : item.pubDate;
return item;
})
diff --git a/lib/routes/shmeea/self-study.ts b/lib/routes/shmeea/self-study.ts
index 1e1dc8d85..ede499ccb 100644
--- a/lib/routes/shmeea/self-study.ts
+++ b/lib/routes/shmeea/self-study.ts
@@ -33,7 +33,7 @@ function load_detail(list, cache) {
title: notice_item('a').attr('title'),
description: detail('.Article_content').html(),
link: url,
- pubDate: timezone(parseDate(detail('.PBtime').text(), 'YYYY-MM-DD HH:mm:ss'), +8),
+ pubDate: timezone(parseDate(detail('.PBtime').text(), 'YYYY-MM-DD HH:mm:ss'), 8),
};
});
})
diff --git a/lib/routes/showstart/service.ts b/lib/routes/showstart/service.ts
index 519233a80..5e9dc1e20 100644
--- a/lib/routes/showstart/service.ts
+++ b/lib/routes/showstart/service.ts
@@ -23,8 +23,8 @@ async function fetchActivityList(
tag: string;
}>
) {
- params.pageNo = params.pageNo || '1';
- params.pageSize = params.pageSize || '30';
+ params.pageNo ||= '1';
+ params.pageSize ||= '30';
const accessToken = await getAccessToken();
const resp = await post('/web/activity/list', accessToken, params);
return resp.result.result.map((item) => formatActivity(item));
@@ -52,8 +52,8 @@ async function fetchPerformerList(
styleId: string;
}>
) {
- params.pageNo = params.pageNo || '1';
- params.pageSize = params.pageSize || '30';
+ params.pageNo ||= '1';
+ params.pageSize ||= '30';
const accessToken = await getAccessToken();
const resp = await post('/web/performer/list', accessToken, params);
return resp.result.result.map((item) => ({
@@ -97,8 +97,8 @@ async function fetchSiteList(
searchKeyword: string;
}>
) {
- params.pageNo = params.pageNo || '1';
- params.pageSize = params.pageSize || '30';
+ params.pageNo ||= '1';
+ params.pageSize ||= '30';
const accessToken = await getAccessToken();
const resp = await post('/web/site/list', accessToken, params);
return resp.result.result.map((item) => ({
@@ -127,8 +127,8 @@ async function fetchBrandList(
searchKeyword: string;
}>
) {
- params.pageNo = params.pageNo || '1';
- params.pageSize = params.pageSize || '30';
+ params.pageNo ||= '1';
+ params.pageSize ||= '30';
const accessToken = await getAccessToken();
const resp = await post('/web/brand/list', accessToken, params);
return resp.result.result.map((item) => ({
diff --git a/lib/routes/shu/global.ts b/lib/routes/shu/global.ts
index 54ea2844c..c1d1f7d3c 100644
--- a/lib/routes/shu/global.ts
+++ b/lib/routes/shu/global.ts
@@ -66,7 +66,7 @@ async function handler(ctx) {
return {
title: item.find('a').text().trim(), // 获取标题
link: rawLink ? new URL(rawLink, rootUrl).href : rootUrl, // 生成完整链接
- pubDate: timezone(parseDate(pubDate, 'YYYY年MM月DD日'), +8), // 解析并转换日期
+ pubDate: timezone(parseDate(pubDate, 'YYYY年MM月DD日'), 8), // 解析并转换日期
description: '', // 没有提供简要描述,设为空字符串
};
});
diff --git a/lib/routes/shu/gs.ts b/lib/routes/shu/gs.ts
index 168b4ab8c..19ccfc812 100644
--- a/lib/routes/shu/gs.ts
+++ b/lib/routes/shu/gs.ts
@@ -68,7 +68,7 @@ async function handler(ctx) {
return {
title, // 获取标题
link: rawLink ? new URL(rawLink, rootUrl).href : rootUrl, // 生成完整链接
- pubDate: timezone(parseDate(dateParts, 'YYYY/MM/DD HH:mm:ss'), +8), // 解析日期
+ pubDate: timezone(parseDate(dateParts, 'YYYY/MM/DD HH:mm:ss'), 8), // 解析日期
description: item.find('td').eq(2).text().trim(), // 提取访问次数或其他信息
};
});
diff --git a/lib/routes/shu/index.ts b/lib/routes/shu/index.ts
index d996e9abb..1d86b049d 100644
--- a/lib/routes/shu/index.ts
+++ b/lib/routes/shu/index.ts
@@ -65,7 +65,7 @@ async function handler(ctx) {
return {
title: item.find('p.bt').text().trim(),
link: rawLink ? new URL(rawLink, rootUrl).href : rootUrl,
- pubDate: timezone(parseDate(item.find('p.sj').text().trim(), 'YYYY.MM.DD'), +8),
+ pubDate: timezone(parseDate(item.find('p.sj').text().trim(), 'YYYY.MM.DD'), 8),
description: item.find('p.zy').text().trim(),
};
});
diff --git a/lib/routes/shu/xxgk.ts b/lib/routes/shu/xxgk.ts
index 41c91d981..8e75c200b 100644
--- a/lib/routes/shu/xxgk.ts
+++ b/lib/routes/shu/xxgk.ts
@@ -68,7 +68,7 @@ async function handler(ctx) {
return {
title, // 获取标题
link: rawLink ? new URL(rawLink, rootUrl).href : rootUrl, // 生成完整链接
- pubDate: timezone(parseDate(pubDate, 'YYYY/MM/DD'), +8), // 解析日期
+ pubDate: timezone(parseDate(pubDate, 'YYYY/MM/DD'), 8), // 解析日期
description: '', // 初始化描述
};
});
diff --git a/lib/routes/shu/xykd.ts b/lib/routes/shu/xykd.ts
index bfd63a6e3..642af4191 100644
--- a/lib/routes/shu/xykd.ts
+++ b/lib/routes/shu/xykd.ts
@@ -69,7 +69,7 @@ async function handler(ctx) {
return {
title: item.find('p.bt').text().trim(), // 获取标题
link: rawLink ? new URL(rawLink, rootUrl).href : rootUrl, // 生成完整链接
- pubDate: timezone(parseDate(`${dateParts[1]}-${dateParts[0]}`, 'MM-DD'), +8), // 拼接并解析日期
+ pubDate: timezone(parseDate(`${dateParts[1]}-${dateParts[0]}`, 'MM-DD'), 8), // 拼接并解析日期
description: item.find('div.zy').text().trim(), // 提取简要描述
};
});
diff --git a/lib/routes/shuiguopai/index.tsx b/lib/routes/shuiguopai/index.tsx
index 4813401b2..d881478a4 100644
--- a/lib/routes/shuiguopai/index.tsx
+++ b/lib/routes/shuiguopai/index.tsx
@@ -51,7 +51,7 @@ async function handler(ctx) {
title: item.title,
guid: item.library_id,
link: `${rootUrl}/play-details/${item.library_id}`,
- pubDate: timezone(parseDate(item.show_time_origin, 'YYYY-MM-DD HH:mm:ss'), +8),
+ pubDate: timezone(parseDate(item.show_time_origin, 'YYYY-MM-DD HH:mm:ss'), 8),
category: item.tags.map((t) => t.tag_title),
}));
diff --git a/lib/routes/sicau/dky.ts b/lib/routes/sicau/dky.ts
index e0f9b2350..d1a838802 100644
--- a/lib/routes/sicau/dky.ts
+++ b/lib/routes/sicau/dky.ts
@@ -54,7 +54,7 @@ async function handler(ctx) {
return {
title: item.text(),
link: `${rootUrl}/${item.attr('href')}`,
- pubDate: timezone(parseDate(item.prev().text(), 'YYYY-MM-DD'), +8),
+ pubDate: timezone(parseDate(item.prev().text(), 'YYYY-MM-DD'), 8),
};
});
diff --git a/lib/routes/sicau/jiaowu.ts b/lib/routes/sicau/jiaowu.ts
index ff421f250..9daad2404 100644
--- a/lib/routes/sicau/jiaowu.ts
+++ b/lib/routes/sicau/jiaowu.ts
@@ -56,7 +56,7 @@ export const route: Route = {
category: [children.eq(1).text()],
link: `${baseUrl}/${a.attr('href')!}`,
title: a.children().first().text(),
- pubDate: timezone(parseDate(children.eq(3).text(), 'YYYY-M-D'), +8),
+ pubDate: timezone(parseDate(children.eq(3).text(), 'YYYY-M-D'), 8),
author: children.eq(4).text(),
description: '请在应用内抓取全文内容',
} as DataItem;
diff --git a/lib/routes/sicau/jk.ts b/lib/routes/sicau/jk.ts
index a04a6d827..c82025266 100644
--- a/lib/routes/sicau/jk.ts
+++ b/lib/routes/sicau/jk.ts
@@ -112,7 +112,7 @@ export const route: Route = {
const { code, message, content } = await $post(`/getActDetail?actId=${item.id}`);
if (code === '0') {
item.author = content.groupName;
- item.pubDate = timezone(parseDate(content.startDate, 'YYYY-MM-DD HH:mm:ss'), +8);
+ item.pubDate = timezone(parseDate(content.startDate, 'YYYY-MM-DD HH:mm:ss'), 8);
item.category = [content.typeName, content.levelName];
item.description = `
${content.description}
`;
diff --git a/lib/routes/sicau/yan.ts b/lib/routes/sicau/yan.ts
index 9cf9dbab0..4df7bb2f5 100644
--- a/lib/routes/sicau/yan.ts
+++ b/lib/routes/sicau/yan.ts
@@ -67,7 +67,7 @@ async function handler(ctx) {
const content = load(detailResponse.data);
item.description = content('.v_news_content').html();
- item.pubDate = timezone(parseDate(detailResponse.data.match(/发布时间: (\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})/)[1], 'YYYY-MM-DD HH:mm:ss'), +8);
+ item.pubDate = timezone(parseDate(detailResponse.data.match(/发布时间: (\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})/)[1], 'YYYY-MM-DD HH:mm:ss'), 8);
return item;
})
diff --git a/lib/routes/simpleinfo/index.tsx b/lib/routes/simpleinfo/index.tsx
index 3240e2551..f4fd83b00 100644
--- a/lib/routes/simpleinfo/index.tsx
+++ b/lib/routes/simpleinfo/index.tsx
@@ -69,7 +69,7 @@ async function handler(ctx) {
const result = await got(item.link);
const content = load(result.data);
item.author = content('meta[property="article:author"]').attr('content');
- item.pubDate = timezone(parseDate(content('meta[property="article:published_time"]').attr('content')), +8);
+ item.pubDate = timezone(parseDate(content('meta[property="article:published_time"]').attr('content')), 8);
item.description = renderDescription({
image: content('meta[property="og:image"]').attr('content'),
description: content('.article-content').first().html(),
diff --git a/lib/routes/sina/utils.tsx b/lib/routes/sina/utils.tsx
index 68c44e813..1259a25ca 100644
--- a/lib/routes/sina/utils.tsx
+++ b/lib/routes/sina/utils.tsx
@@ -41,7 +41,7 @@ const parseArticle = (item, tryGet) =>
const htmlPubDate = $('#pub_date, .date');
const htmlDate = htmlPubDate.length ? timezone(parseDate(htmlPubDate.text(), ['YYYY年MM月DD日 HH:mm', 'YYYY年MM月DD日HH:mm']), 8) : null;
const metaDate = metaPublishTime.length ? parseDate(metaPublishTime.attr('content')) : htmlDate; // 2023-05-08T08:39:31+08:00
- item.pubDate = item.pubDate ?? metaDate;
+ item.pubDate ??= metaDate;
item.author = $('meta[property="article:author"]').attr('content');
if (item.link.startsWith('https://slide.sports.sina.com.cn/') || item.link.startsWith('https://slide.tech.sina.com.cn/')) {
diff --git a/lib/routes/sinchew/index.tsx b/lib/routes/sinchew/index.tsx
index 65873e01d..e34462f1b 100644
--- a/lib/routes/sinchew/index.tsx
+++ b/lib/routes/sinchew/index.tsx
@@ -44,7 +44,7 @@ async function handler(ctx) {
return {
title: item.attr('data-title'),
link: link.startsWith('http') ? link : `${rootUrl}${link}`,
- pubDate: timezone(parseDate(item.text()), +8),
+ pubDate: timezone(parseDate(item.text()), 8),
};
});
@@ -72,7 +72,7 @@ async function handler(ctx) {
});
item.description = content('.article-page-content').html();
- item.pubDate = timezone(parseDate(content('meta[property="article:published_time"]').attr('content')), +8);
+ item.pubDate = timezone(parseDate(content('meta[property="article:published_time"]').attr('content')), 8);
return item;
})
diff --git a/lib/routes/sis001/common.ts b/lib/routes/sis001/common.ts
index 89b8a12d7..cb53515c4 100644
--- a/lib/routes/sis001/common.ts
+++ b/lib/routes/sis001/common.ts
@@ -53,7 +53,7 @@ async function getThread(cookie: string, item: DataItem) {
$('.postinfo')
.eq(0)
.text()
- .match(/发表于 (.*)(?:[\n\r\u2028\u2029]\s*)?只看该作者/)[1],
+ .match(/发表于 (.*)(?:[\n\r\u{2028}\u{2029}]\s*)?只看该作者/u)[1],
'YYYY-M-D HH:mm'
),
8
@@ -64,8 +64,8 @@ async function getThread(cookie: string, item: DataItem) {
.eq(0)
.html()
?.replaceAll('\n', '')
- .replaceAll(/\u3000{2}.+?(((?:
){2})|( ))/g, (str) => `${str.replaceAll('
', '')}
`)
- .replaceAll(/\u3000{6,}([^\u3000\n\r\u2028\u2029].*?|\u3000)<\/p>/g, '
$1
')
+ .replaceAll(/\u{3000}{2}.+?(((?:
){2})|( ))/gu, (str) => `${str.replaceAll('
', '')}
`)
+ .replaceAll(/\u{3000}{6,}([^\u{3000}\n\r\u{2028}\u{2029}].*?|\u{3000})<\/p>/gu, '
$1
')
.replaceAll(' ', '')
.replace(/
+
/, '') + ($('.defaultpost .postattachlist').html() ?? '');
return item;
diff --git a/lib/routes/sjtu/cs/tzgg.tsx b/lib/routes/sjtu/cs/tzgg.tsx
index 4a543e329..bd6027f6e 100644
--- a/lib/routes/sjtu/cs/tzgg.tsx
+++ b/lib/routes/sjtu/cs/tzgg.tsx
@@ -77,14 +77,14 @@ function enrichItem(item: ListItem): Promise {
let pubDate: Date | undefined;
if (publishedMatch) {
const [, y, m, d] = publishedMatch;
- pubDate = timezone(parseDate(`${y}-${m.padStart(2, '0')}-${d.padStart(2, '0')}`, 'YYYY-MM-DD'), +8);
+ pubDate = timezone(parseDate(`${y}-${m.padStart(2, '0')}-${d.padStart(2, '0')}`, 'YYYY-MM-DD'), 8);
}
return {
title: item.title,
link: item.link,
description: $txt.html() ?? '',
- pubDate: pubDate ?? timezone(parseDate(item.date, 'YYYY-MM-DD'), +8),
+ pubDate: pubDate ?? timezone(parseDate(item.date, 'YYYY-MM-DD'), 8),
};
}) as Promise;
}
@@ -147,7 +147,7 @@ async function handler(ctx): Promise {
: {
title: items[index].title,
link: items[index].link,
- pubDate: timezone(parseDate(items[index].date, 'YYYY-MM-DD'), +8),
+ pubDate: timezone(parseDate(items[index].date, 'YYYY-MM-DD'), 8),
}
);
diff --git a/lib/routes/sjtu/cs/xshd.tsx b/lib/routes/sjtu/cs/xshd.tsx
index bda4107aa..ec985124a 100644
--- a/lib/routes/sjtu/cs/xshd.tsx
+++ b/lib/routes/sjtu/cs/xshd.tsx
@@ -63,7 +63,7 @@ function publishDateFromImage(imageUrl: string): Date | undefined {
return undefined;
}
const [, y, mo, d] = m;
- return timezone(parseDate(`${y}-${mo}-${d}`, 'YYYY-MM-DD'), +8);
+ return timezone(parseDate(`${y}-${mo}-${d}`, 'YYYY-MM-DD'), 8);
}
function renderDescription(item: ListItem): string {
@@ -136,7 +136,7 @@ function enrichItem(item: ListItem): Promise {
const publishedMatch = publishedText.match(/(\d{4})-(\d{1,2})-(\d{1,2})/);
if (publishedMatch) {
const [, y, m, d] = publishedMatch;
- pubDate = timezone(parseDate(`${y}-${m.padStart(2, '0')}-${d.padStart(2, '0')}`, 'YYYY-MM-DD'), +8);
+ pubDate = timezone(parseDate(`${y}-${m.padStart(2, '0')}-${d.padStart(2, '0')}`, 'YYYY-MM-DD'), 8);
}
}
}
diff --git a/lib/routes/sjtu/gs.ts b/lib/routes/sjtu/gs.ts
index 7d7df1560..159b7db3e 100644
--- a/lib/routes/sjtu/gs.ts
+++ b/lib/routes/sjtu/gs.ts
@@ -70,7 +70,7 @@ async function handler(ctx) {
return {
title: item.find('.title').text().trim(),
link: `${item.attr('href').startsWith('http') ? '' : rootUrl}${item.attr('href')}`,
- pubDate: timezone(parseDate(`${year}-${day}`, 'YYYY-MM-DD'), +8),
+ pubDate: timezone(parseDate(`${year}-${day}`, 'YYYY-MM-DD'), 8),
};
});
diff --git a/lib/routes/sjtu/seiee/index.ts b/lib/routes/sjtu/seiee/index.ts
index f07c8140d..b2cc7efeb 100644
--- a/lib/routes/sjtu/seiee/index.ts
+++ b/lib/routes/sjtu/seiee/index.ts
@@ -82,7 +82,7 @@ async function handler(ctx) {
.trim()
.match(/日期:([\d-]+) /)[1]
),
- +8
+ 8
);
return item;
diff --git a/lib/routes/smzdm/article.ts b/lib/routes/smzdm/article.ts
index 8a19c4aff..2fcaf425d 100644
--- a/lib/routes/smzdm/article.ts
+++ b/lib/routes/smzdm/article.ts
@@ -58,7 +58,7 @@ async function handler(ctx) {
return {
title: item.find('.pandect-content-title a').text(),
link: item.find('.pandect-content-title a').attr('href'),
- pubDate: timezone(parseDate(item.find('.pandect-content-time').text(), ['YYYY-MM-DD', 'MM-DD HH:mm']), +8),
+ pubDate: timezone(parseDate(item.find('.pandect-content-time').text(), ['YYYY-MM-DD', 'MM-DD HH:mm']), 8),
};
});
diff --git a/lib/routes/smzdm/baoliao.ts b/lib/routes/smzdm/baoliao.ts
index bc89f17c2..376d888bb 100644
--- a/lib/routes/smzdm/baoliao.ts
+++ b/lib/routes/smzdm/baoliao.ts
@@ -58,7 +58,7 @@ async function handler(ctx) {
return {
title: item.find('.pandect-content-title a').text(),
link: item.find('.pandect-content-title a').attr('href'),
- pubDate: timezone(parseDate(item.find('.pandect-content-time').text(), ['YYYY-MM-DD', 'MM-DD HH:mm']), +8),
+ pubDate: timezone(parseDate(item.find('.pandect-content-time').text(), ['YYYY-MM-DD', 'MM-DD HH:mm']), 8),
};
});
diff --git a/lib/routes/smzdm/keyword.ts b/lib/routes/smzdm/keyword.ts
index efc2b825b..9ccc0491b 100644
--- a/lib/routes/smzdm/keyword.ts
+++ b/lib/routes/smzdm/keyword.ts
@@ -70,7 +70,7 @@ async function handler(ctx) {
return {
title: `${item.find('.feed-block-title a').eq(0).text().trim()} - ${item.find('.feed-block-title a').eq(1).text().trim()}`,
description: `${item.find('.feed-block-descripe').contents().eq(2).text().trim()}
${item.find('.feed-block-extras span').text().trim()}
`,
- pubDate: timezone(parseDate(item.find('.feed-block-extras').contents().eq(0).text().trim(), ['MM-DD HH:mm', 'HH:mm']), +8),
+ pubDate: timezone(parseDate(item.find('.feed-block-extras').contents().eq(0).text().trim(), ['MM-DD HH:mm', 'HH:mm']), 8),
link: item.find('.feed-block-title a').attr('href'),
};
}),
diff --git a/lib/routes/smzdm/ranking.ts b/lib/routes/smzdm/ranking.ts
index 5c889e306..ea8ba8ab9 100644
--- a/lib/routes/smzdm/ranking.ts
+++ b/lib/routes/smzdm/ranking.ts
@@ -252,7 +252,7 @@ async function handler(ctx) {
item: list.map((item) => ({
title: `${item.article_title} - ${item.article_price}`,
description: `${item.article_title} - ${item.article_price}
`,
- pubDate: timezone(item.article_pubdate, +8),
+ pubDate: timezone(item.article_pubdate, 8),
link: item.article_url,
})),
};
diff --git a/lib/routes/sobooks/date.ts b/lib/routes/sobooks/date.ts
index aa958e205..c544845c0 100644
--- a/lib/routes/sobooks/date.ts
+++ b/lib/routes/sobooks/date.ts
@@ -1,6 +1,6 @@
import type { Route } from '@/types';
-import utils from './utils';
+import { utils } from './utils';
export const route: Route = {
path: '/date/:date?',
diff --git a/lib/routes/sobooks/index.ts b/lib/routes/sobooks/index.ts
index 0c90598e2..c75f7fef3 100644
--- a/lib/routes/sobooks/index.ts
+++ b/lib/routes/sobooks/index.ts
@@ -1,6 +1,6 @@
import type { Route } from '@/types';
-import utils from './utils';
+import { utils } from './utils';
export const route: Route = {
path: '/:category?',
diff --git a/lib/routes/sobooks/tag.ts b/lib/routes/sobooks/tag.ts
index 3fe68508f..12ed795d8 100644
--- a/lib/routes/sobooks/tag.ts
+++ b/lib/routes/sobooks/tag.ts
@@ -1,6 +1,6 @@
import type { Route } from '@/types';
-import utils from './utils';
+import { utils } from './utils';
export const route: Route = {
path: '/tag/:id?',
diff --git a/lib/routes/sobooks/utils.ts b/lib/routes/sobooks/utils.ts
index 902a264d9..562e92b41 100644
--- a/lib/routes/sobooks/utils.ts
+++ b/lib/routes/sobooks/utils.ts
@@ -4,7 +4,7 @@ import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
-const utils = async (ctx, currentUrl) => {
+export const utils = async (ctx, currentUrl) => {
const rootUrl = 'https://www.sobooks.net';
currentUrl = `${rootUrl}/${currentUrl}`;
const response = await got({
@@ -50,4 +50,3 @@ const utils = async (ctx, currentUrl) => {
item: items,
};
};
-export default utils;
diff --git a/lib/routes/sohu/mobile.ts b/lib/routes/sohu/mobile.ts
index 443ce4ec0..d043de6b5 100644
--- a/lib/routes/sohu/mobile.ts
+++ b/lib/routes/sohu/mobile.ts
@@ -86,21 +86,23 @@ async function handler() {
function extractPlateBlockNewsLists(jsonData: any) {
const result: any[] = [];
for (const [key, plateBlock] of Object.entries(jsonData)) {
- if (key.startsWith('PlateBlock')) {
- // 处理新闻列表
- if (plateBlock?.param?.newsData?.list) {
- result.push(...plateBlock.param.newsData.list);
- }
- // 处理焦点图数据
- if (plateBlock?.param?.focusData?.list) {
- result.push(...plateBlock.param.focusData.list);
- }
- if (plateBlock?.param?.feedData0?.list) {
- result.push(...plateBlock.param.feedData0.list);
- }
- if (plateBlock?.param?.feedData1?.list) {
- result.push(...plateBlock.param.feedData1.list);
- }
+ if (!key.startsWith('PlateBlock')) {
+ continue;
+ }
+
+ // 处理新闻列表
+ if (plateBlock?.param?.newsData?.list) {
+ result.push(...plateBlock.param.newsData.list);
+ }
+ // 处理焦点图数据
+ if (plateBlock?.param?.focusData?.list) {
+ result.push(...plateBlock.param.focusData.list);
+ }
+ if (plateBlock?.param?.feedData0?.list) {
+ result.push(...plateBlock.param.feedData0.list);
+ }
+ if (plateBlock?.param?.feedData1?.list) {
+ result.push(...plateBlock.param.feedData1.list);
}
}
return result;
diff --git a/lib/routes/sohu/mp.tsx b/lib/routes/sohu/mp.tsx
index d295920ef..2cc23572f 100644
--- a/lib/routes/sohu/mp.tsx
+++ b/lib/routes/sohu/mp.tsx
@@ -60,7 +60,7 @@ function fetchArticle(item) {
const $ = cheerio.load(response);
$('.original-title, .lookall-box').remove();
- item.author = item.author || $('span[data-role="original-link"] a').text();
+ item.author ||= $('span[data-role="original-link"] a').text();
item.pubDate = timezone(parseDate($('meta[itemprop="dateUpdate"]').attr('content')), 8);
if (/window\.sohu_mp\.article_video/.test($('script').text())) {
diff --git a/lib/routes/solidot/_article.ts b/lib/routes/solidot/_article.ts
index 387a7e5b4..39d28f8d5 100644
--- a/lib/routes/solidot/_article.ts
+++ b/lib/routes/solidot/_article.ts
@@ -41,7 +41,7 @@ export default async function get_article(url) {
const item = {
title,
- pubDate: timezone(parseDate(date_str), +8),
+ pubDate: timezone(parseDate(date_str), 8),
author,
link: url,
description,
diff --git a/lib/routes/southcn/nfapp/column.ts b/lib/routes/southcn/nfapp/column.ts
index 30d20cc4a..d69359fc5 100644
--- a/lib/routes/southcn/nfapp/column.ts
+++ b/lib/routes/southcn/nfapp/column.ts
@@ -56,7 +56,7 @@ async function handler(ctx) {
thumb: item.picMiddle,
description: item.summary === '详见内文' ? '' : item.summary,
}),
- pubDate: timezone(parseDate(item.updateTime), +8),
+ pubDate: timezone(parseDate(item.updateTime), 8),
link: `http://pc.nfapp.southcn.com/${item.columnId}/${item.articleId}.html`,
articleId: item.articleId,
shareUrl: item.shareUrl,
diff --git a/lib/routes/southcn/nfapp/reporter.ts b/lib/routes/southcn/nfapp/reporter.ts
index b283af4ea..b035dca11 100644
--- a/lib/routes/southcn/nfapp/reporter.ts
+++ b/lib/routes/southcn/nfapp/reporter.ts
@@ -38,7 +38,7 @@ async function handler(ctx) {
thumb: item.picMiddle,
description: item.attAbstract,
}),
- pubDate: timezone(parseDate(item.publishtime), +8),
+ pubDate: timezone(parseDate(item.publishtime), 8),
link: `http://pc.nfapp.southcn.com/${item.colID}/${item.fileId}.html`,
articleId: item.fileId,
shareUrl: item.shareUrl,
diff --git a/lib/routes/sqmc/www.ts b/lib/routes/sqmc/www.ts
index 1f3eb5af1..7a6d3ca6c 100644
--- a/lib/routes/sqmc/www.ts
+++ b/lib/routes/sqmc/www.ts
@@ -67,7 +67,7 @@ async function handler(ctx) {
title: item.find('dt a').text(),
description: content('div.Tr_Detail').html(),
link,
- pubDate: timezone(pubDate, +8),
+ pubDate: timezone(pubDate, 8),
};
});
diff --git a/lib/routes/sse/sselawsrules.ts b/lib/routes/sse/sselawsrules.ts
index 4f630a7d6..feb2d3fe7 100644
--- a/lib/routes/sse/sselawsrules.ts
+++ b/lib/routes/sse/sselawsrules.ts
@@ -56,7 +56,7 @@ export const handler = async (ctx) => {
.split(/时间\s/)
.pop()
),
- +8
+ 8
)
: undefined;
diff --git a/lib/routes/sspai/shortcuts-gallery.ts b/lib/routes/sspai/shortcuts-gallery.ts
index 88a05ae6a..214536d8d 100644
--- a/lib/routes/sspai/shortcuts-gallery.ts
+++ b/lib/routes/sspai/shortcuts-gallery.ts
@@ -31,19 +31,15 @@ async function handler() {
data: { data: categories },
} = await got('https://shortcuts.sspai.com/api/v1/user/workflow/all/get');
- const items = [];
-
- for (const category of categories) {
- for (const shortcut of category.data || []) {
- items.push({
- title: shortcut.name,
- description: `作者:${shortcut.author_id}
${decodeURIComponent((shortcut.description || '').replaceAll('+', '%20'))}`,
- pubDate: parseDate(shortcut.utime * 1000),
- guid: shortcut.id,
- link: shortcut.url,
- });
- }
- }
+ const items = categories.flatMap((category) =>
+ (category.data || []).map((shortcut) => ({
+ title: shortcut.name,
+ description: `作者:${shortcut.author_id}
${decodeURIComponent((shortcut.description || '').replaceAll('+', '%20'))}`,
+ pubDate: parseDate(shortcut.utime * 1000),
+ guid: shortcut.id,
+ link: shortcut.url,
+ }))
+ );
return {
title: 'Shortcuts Gallery - 少数派',
diff --git a/lib/routes/sspu/jwc.ts b/lib/routes/sspu/jwc.ts
index dfcfaa323..b6a61a19a 100644
--- a/lib/routes/sspu/jwc.ts
+++ b/lib/routes/sspu/jwc.ts
@@ -44,7 +44,7 @@ async function handler(ctx) {
const $ = load(response);
item.description = $('.wp_articlecontent').html();
- item.pubDate = timezone(parseDate($('.arti_update').text(), 'YYYY-MM-DD HH:mm:ss'), +8);
+ item.pubDate = timezone(parseDate($('.arti_update').text(), 'YYYY-MM-DD HH:mm:ss'), 8);
return item;
})
diff --git a/lib/routes/stbu/jsjxy.ts b/lib/routes/stbu/jsjxy.ts
index f386fa4e3..aece3ccf6 100644
--- a/lib/routes/stbu/jsjxy.ts
+++ b/lib/routes/stbu/jsjxy.ts
@@ -63,7 +63,7 @@ async function handler() {
});
const $ = load(gbk2utf8(response));
item.description = $('.content14').first().html().trim();
- item.pubDate = timezone(parseDate($('.article .source').text().split('日期:', 2)[1].replace('\n', '').trim()), +8);
+ item.pubDate = timezone(parseDate($('.article .source').text().split('日期:', 2)[1].replace('\n', '').trim()), 8);
return item;
})
)
diff --git a/lib/routes/stbu/xyxw.ts b/lib/routes/stbu/xyxw.ts
index 95518bf02..aca98f09f 100644
--- a/lib/routes/stbu/xyxw.ts
+++ b/lib/routes/stbu/xyxw.ts
@@ -58,7 +58,7 @@ async function handler() {
});
const $ = load(gbk2utf8(response));
item.description = $('.artmainl .articlemain').first().html();
- item.pubDate = timezone(parseDate($('.artmainl .info').text().split('|', 3)[2].split(':', 2)[1].trim()), +8);
+ item.pubDate = timezone(parseDate($('.artmainl .info').text().split('|', 3)[2].split(':', 2)[1].trim()), 8);
return item;
})
)
diff --git a/lib/routes/stcn/index.ts b/lib/routes/stcn/index.ts
index 078d0957f..3110ccf99 100644
--- a/lib/routes/stcn/index.ts
+++ b/lib/routes/stcn/index.ts
@@ -42,7 +42,7 @@ export const handler = async (ctx: Context): Promise => {
const processedItem: DataItem = {
title,
description,
- pubDate: pubDateStr ? timezone(parseDate(pubDateStr, ['HH:mm', 'MM-DD HH:mm', 'YYYY-MM-DD HH:mm']), +8) : undefined,
+ pubDate: pubDateStr ? timezone(parseDate(pubDateStr, ['HH:mm', 'MM-DD HH:mm', 'YYYY-MM-DD HH:mm']), 8) : undefined,
link: linkUrl ? new URL(linkUrl, baseUrl).href : undefined,
category: categories,
author: authors,
@@ -52,7 +52,7 @@ export const handler = async (ctx: Context): Promise => {
},
image,
banner: image,
- updated: upDatedStr ? timezone(parseDate(upDatedStr, ['HH:mm', 'MM-DD HH:mm', 'YYYY-MM-DD HH:mm']), +8) : undefined,
+ updated: upDatedStr ? timezone(parseDate(upDatedStr, ['HH:mm', 'MM-DD HH:mm', 'YYYY-MM-DD HH:mm']), 8) : undefined,
language,
};
@@ -80,14 +80,14 @@ export const handler = async (ctx: Context): Promise => {
const processedItem: DataItem = {
title,
description,
- pubDate: pubDateStr ? timezone(parseDate(pubDateStr), +8) : item.pubDate,
+ pubDate: pubDateStr ? timezone(parseDate(pubDateStr), 8) : item.pubDate,
category: categories,
author: authors,
content: {
html: description,
text: description,
},
- updated: upDatedStr ? timezone(parseDate(upDatedStr), +8) : item.updated,
+ updated: upDatedStr ? timezone(parseDate(upDatedStr), 8) : item.updated,
language,
};
diff --git a/lib/routes/stcn/kx.ts b/lib/routes/stcn/kx.ts
index 7425f6e93..d55bb8b61 100644
--- a/lib/routes/stcn/kx.ts
+++ b/lib/routes/stcn/kx.ts
@@ -81,14 +81,14 @@ export const handler = async (ctx: Context): Promise => {
const processedItem: DataItem = {
title,
description,
- pubDate: pubDateStr ? timezone(parseDate(pubDateStr), +8) : item.pubDate,
+ pubDate: pubDateStr ? timezone(parseDate(pubDateStr), 8) : item.pubDate,
category: categories,
author: authors,
content: {
html: description,
text: description,
},
- updated: upDatedStr ? timezone(parseDate(upDatedStr), +8) : item.updated,
+ updated: upDatedStr ? timezone(parseDate(upDatedStr), 8) : item.updated,
language,
};
diff --git a/lib/routes/stcn/rank.ts b/lib/routes/stcn/rank.ts
index efae34912..e50753f3f 100644
--- a/lib/routes/stcn/rank.ts
+++ b/lib/routes/stcn/rank.ts
@@ -64,14 +64,14 @@ export const handler = async (ctx: Context): Promise => {
const processedItem: DataItem = {
title,
description,
- pubDate: pubDateStr ? timezone(parseDate(pubDateStr), +8) : item.pubDate,
+ pubDate: pubDateStr ? timezone(parseDate(pubDateStr), 8) : item.pubDate,
category: categories,
author: authors,
content: {
html: description,
text: description,
},
- updated: upDatedStr ? timezone(parseDate(upDatedStr), +8) : item.updated,
+ updated: upDatedStr ? timezone(parseDate(upDatedStr), 8) : item.updated,
language,
};
diff --git a/lib/routes/stdaily/digitalpaper.tsx b/lib/routes/stdaily/digitalpaper.tsx
index 91f4b780a..86bf943d7 100644
--- a/lib/routes/stdaily/digitalpaper.tsx
+++ b/lib/routes/stdaily/digitalpaper.tsx
@@ -99,7 +99,7 @@ async function handler() {
{articleVo.content ? raw(articleVo.content) : null}
>
),
- pubDate: timezone(parseDate(articleVo.periodTime), +8),
+ pubDate: timezone(parseDate(articleVo.periodTime), 8),
author: articleVo.author,
link: `https://epaper.stdaily.com/statics/technology-site/index.html#/home?isDetail=1¤tNewsId=${article.id}¤tVersionName=${articleVo.editionName}¤tVersion=${Number(section.editionCode)}&timeValue=${articleVo.periodTime}`,
} as DataItem;
diff --git a/lib/routes/straitstimes/index.tsx b/lib/routes/straitstimes/index.tsx
index cecc468d6..1b6142b00 100644
--- a/lib/routes/straitstimes/index.tsx
+++ b/lib/routes/straitstimes/index.tsx
@@ -89,10 +89,12 @@ async function handler(ctx) {
let slug = section && sections.has(`${category}-${section}-more/star`) ? `${category}-${section}-more/star` : undefined;
if (section === undefined) {
for (const section of ['latest', 'top-picks', 'top-stories']) {
- if (sections.has(`${category}-${section}-more/star`)) {
- slug = `${category}-${section}-more/star`;
- break;
+ if (!sections.has(`${category}-${section}-more/star`)) {
+ continue;
}
+
+ slug = `${category}-${section}-more/star`;
+ break;
}
}
if (slug) {
diff --git a/lib/routes/studygolang/utils.ts b/lib/routes/studygolang/utils.ts
index 7fec467bb..2bea87ca5 100644
--- a/lib/routes/studygolang/utils.ts
+++ b/lib/routes/studygolang/utils.ts
@@ -55,7 +55,7 @@ const FetchGoItems = async (ctx, rewriteId) => {
const content = load(detailResponse.data);
- item.pubDate = timezone(parseDate(content('.timeago').first().attr('title')), +8);
+ item.pubDate = timezone(parseDate(content('.timeago').first().attr('title')), 8);
try {
item.description = md.render(content('.content').html());
diff --git a/lib/routes/subhd/index.ts b/lib/routes/subhd/index.ts
index e81600b29..b836ff717 100644
--- a/lib/routes/subhd/index.ts
+++ b/lib/routes/subhd/index.ts
@@ -56,7 +56,7 @@ async function handler(ctx) {
return {
link: `${rootUrl}${item.attr('href')}`,
author: item.parent().parent().find('.text-dark').last().text(),
- pubDate: timezone(parseDate(pubDate.includes('-') ? pubDate : `${today} ${pubDate}`), +8),
+ pubDate: timezone(parseDate(pubDate.includes('-') ? pubDate : `${today} ${pubDate}`), 8),
title: `${item.parent().parent().find('.align-middle').text()} ${item.text().replace(/ - SubHD/, '')}`,
};
});
diff --git a/lib/routes/swpu/bgw.ts b/lib/routes/swpu/bgw.ts
index 852426039..1939055c9 100644
--- a/lib/routes/swpu/bgw.ts
+++ b/lib/routes/swpu/bgw.ts
@@ -49,7 +49,7 @@ async function handler(ctx): Promise {
.toArray()
.map((elem) => ({
title: $(elem.children[0]).text(),
- pubDate: timezone(parseDate($(elem.children[1]).text()), +8),
+ pubDate: timezone(parseDate($(elem.children[1]).text()), 8),
link: joinUrl('https://www.swpu.edu.cn', $(elem).attr('href')), // 实际获得连接 "../info/1312/17891.htm"
}));
@@ -67,10 +67,12 @@ async function handler(ctx): Promise {
item.author = '办公网';
item.description = $('.v_news_content').html()!;
for (const elem of $('.v_news_content p')) {
- if ($(elem).css('text-align') === 'right') {
- item.author = $(elem).text();
- break;
+ if ($(elem).css('text-align') !== 'right') {
+ continue;
}
+
+ item.author = $(elem).text();
+ break;
}
}
return item;
diff --git a/lib/routes/swpu/cjxy.ts b/lib/routes/swpu/cjxy.ts
index 2fbe22345..ead52550c 100644
--- a/lib/routes/swpu/cjxy.ts
+++ b/lib/routes/swpu/cjxy.ts
@@ -47,7 +47,7 @@ async function handler(ctx) {
.toArray()
.map((elem) => ({
title: $('a[href]', elem).text().trim(),
- pubDate: timezone(parseDate($('span', elem).text(), 'YYYY年MM月DD日'), +8),
+ pubDate: timezone(parseDate($('span', elem).text(), 'YYYY年MM月DD日'), 8),
link: `https://www.swpu.edu.cn/nccjxy/${$('a[href]', elem).attr('href').split('../', 2)[1]}`,
}));
@@ -63,10 +63,12 @@ async function handler(ctx) {
item.author = '财经学院';
item.description = $('.v_news_content').html();
for (const elem of $('.v_news_content p')) {
- if ($(elem).css('text-align') === 'right') {
- item.author = $(elem).text();
- break;
+ if ($(elem).css('text-align') !== 'right') {
+ continue;
}
+
+ item.author = $(elem).text();
+ break;
}
}
return item;
diff --git a/lib/routes/swpu/dean.ts b/lib/routes/swpu/dean.ts
index cf3403eb1..af8e3860f 100644
--- a/lib/routes/swpu/dean.ts
+++ b/lib/routes/swpu/dean.ts
@@ -66,12 +66,14 @@ async function handler(ctx): Promise {
} else {
item.author = '教务处';
item.description = $('.v_news_content').html()!;
- item.pubDate = timezone(parseDate($('#lbDate').text(), '更新时间:YYYY年MM月DD日'), +8);
+ item.pubDate = timezone(parseDate($('#lbDate').text(), '更新时间:YYYY年MM月DD日'), 8);
for (const elem of $('.v_news_content p')) {
- if ($(elem).css('text-align') === 'right') {
- item.author = $(elem).text();
- break;
+ if ($(elem).css('text-align') !== 'right') {
+ continue;
}
+
+ item.author = $(elem).text();
+ break;
}
}
return item;
diff --git a/lib/routes/swpu/dxy.ts b/lib/routes/swpu/dxy.ts
index b5258d907..c8a8f4fa6 100644
--- a/lib/routes/swpu/dxy.ts
+++ b/lib/routes/swpu/dxy.ts
@@ -52,7 +52,7 @@ async function handler(ctx): Promise {
.toArray()
.map((elem) => ({
title: $('a[title]', elem).text().trim(),
- pubDate: timezone(parseDate($('td:eq(1)', elem).text(), 'YYYY年MM月DD日'), +8),
+ pubDate: timezone(parseDate($('td:eq(1)', elem).text(), 'YYYY年MM月DD日'), 8),
link: joinUrl('https://www.swpu.edu.cn/dxy/', $('a[title]', elem).attr('href')),
}));
@@ -70,10 +70,12 @@ async function handler(ctx): Promise {
item.author = '电气信息学院';
item.description = $('.v_news_content').html()!;
for (const elem of $('.v_news_content p')) {
- if ($(elem).css('text-align') === 'right') {
- item.author = $(elem).text();
- break;
+ if ($(elem).css('text-align') !== 'right') {
+ continue;
}
+
+ item.author = $(elem).text();
+ break;
}
}
return item;
diff --git a/lib/routes/swpu/is.ts b/lib/routes/swpu/is.ts
index 122b34636..977a480c4 100644
--- a/lib/routes/swpu/is.ts
+++ b/lib/routes/swpu/is.ts
@@ -47,7 +47,7 @@ async function handler(ctx) {
.toArray()
.map((elem) => ({
title: $('a[title]', elem).text().trim(),
- pubDate: timezone(parseDate($('td:eq(1)', elem).text(), 'YYYY年MM月DD日'), +8),
+ pubDate: timezone(parseDate($('td:eq(1)', elem).text(), 'YYYY年MM月DD日'), 8),
link: `https://www.swpu.edu.cn/is/${$('a[href]', elem).attr('href').split('../', 2)[1]}`,
}));
@@ -63,10 +63,12 @@ async function handler(ctx) {
item.author = '学院';
item.description = $('.v_news_content').html();
for (const elem of $('.v_news_content p')) {
- if ($(elem).css('text-align') === 'right') {
- item.author = $(elem).text();
- break;
+ if ($(elem).css('text-align') !== 'right') {
+ continue;
}
+
+ item.author = $(elem).text();
+ break;
}
}
return item;
diff --git a/lib/routes/swpu/scs.ts b/lib/routes/swpu/scs.ts
index f1999ef09..8f223a641 100644
--- a/lib/routes/swpu/scs.ts
+++ b/lib/routes/swpu/scs.ts
@@ -49,7 +49,7 @@ async function handler(ctx): Promise {
.toArray()
.map((elem) => ({
title: $('em', elem).text().trim(),
- pubDate: timezone(parseDate($('span', elem).text()), +8),
+ pubDate: timezone(parseDate($('span', elem).text()), 8),
link: joinUrl('https://www.swpu.edu.cn/scs/index/', $('a', elem).attr('href')),
}));
@@ -67,10 +67,12 @@ async function handler(ctx): Promise {
item.author = '计算机与软件学院';
item.description = $('.v_news_content').html()!;
for (const elem of $('.v_news_content p')) {
- if ($(elem).css('text-align') === 'right') {
- item.author = $(elem).text();
- break;
+ if ($(elem).css('text-align') !== 'right') {
+ continue;
}
+
+ item.author = $(elem).text();
+ break;
}
}
return item;
diff --git a/lib/routes/swpu/utils.ts b/lib/routes/swpu/utils.ts
index 4ae3ccdd1..6af4e6857 100644
--- a/lib/routes/swpu/utils.ts
+++ b/lib/routes/swpu/utils.ts
@@ -8,7 +8,7 @@ function joinUrl(url1, url2) {
}
if (!url1.endsWith('/')) {
- url1 = url1 + '/';
+ url1 += '/';
}
if (url2.startsWith('/')) {
url2 = url2.slice(1);
diff --git a/lib/routes/syosetu/ranking-isekai.ts b/lib/routes/syosetu/ranking-isekai.ts
index dd4184a8e..7bba60dc1 100644
--- a/lib/routes/syosetu/ranking-isekai.ts
+++ b/lib/routes/syosetu/ranking-isekai.ts
@@ -78,7 +78,7 @@ export async function handleIsekaiRanking(type: string, limit: number): Promise<
link: `https://ncode.syosetu.com/${String(novel.ncode).toLowerCase()}`,
description: renderDescription({ novel }),
author: novel.writer,
- category: novel.keyword.split(/[\s/\uFF0F]/).filter(Boolean),
+ category: novel.keyword.split(/[\s/\u{FF0F}]/u).filter(Boolean),
}));
return {
diff --git a/lib/routes/syosetu/ranking-r18.ts b/lib/routes/syosetu/ranking-r18.ts
index 553564e4b..abc8cfaa5 100644
--- a/lib/routes/syosetu/ranking-r18.ts
+++ b/lib/routes/syosetu/ranking-r18.ts
@@ -176,7 +176,7 @@ async function handler(ctx: Context): Promise {
link: `https://novel18.syosetu.com/${String(novel.ncode).toLowerCase()}`,
description: renderDescription({ novel }),
author: novel.writer,
- category: novel.keyword.split(/[\s/\uFF0F]/).filter(Boolean),
+ category: novel.keyword.split(/[\s/\u{FF0F}]/u).filter(Boolean),
}));
return {
diff --git a/lib/routes/syosetu/ranking.ts b/lib/routes/syosetu/ranking.ts
index 451634341..46293c0af 100644
--- a/lib/routes/syosetu/ranking.ts
+++ b/lib/routes/syosetu/ranking.ts
@@ -267,7 +267,7 @@ async function handler(ctx: Context): Promise {
link: `https://ncode.syosetu.com/${String(novel.ncode).toLowerCase()}`,
description: renderDescription({ novel }),
author: novel.writer,
- category: novel.keyword.split(/[\s/\uFF0F]/).filter(Boolean),
+ category: novel.keyword.split(/[\s/\u{FF0F}]/u).filter(Boolean),
}));
return {
diff --git a/lib/routes/syosetu/search.ts b/lib/routes/syosetu/search.ts
index ff0ac544e..30d43cb77 100644
--- a/lib/routes/syosetu/search.ts
+++ b/lib/routes/syosetu/search.ts
@@ -139,7 +139,7 @@ async function handler(ctx: Context): Promise {
// pubDate: novel.general_lastup,
author: novel.writer,
// Split by whitespace characters(\s), slash(/), full-width slash(/)
- category: novel.keyword.split(/[\s/\uFF0F]/).filter(Boolean),
+ category: novel.keyword.split(/[\s/\u{FF0F}]/u).filter(Boolean),
}));
const searchTerms: string[] = [];
diff --git a/lib/routes/szse/disclosure/listed-notice.ts b/lib/routes/szse/disclosure/listed-notice.ts
index d95b4ab59..b3ee6d8d7 100644
--- a/lib/routes/szse/disclosure/listed-notice.ts
+++ b/lib/routes/szse/disclosure/listed-notice.ts
@@ -82,12 +82,12 @@ export const handler = async (ctx: Context): Promise => {
let processedItem: DataItem = {
title,
- pubDate: pubDate ? timezone(parseDate(pubDate), +8) : undefined,
+ pubDate: pubDate ? timezone(parseDate(pubDate), 8) : undefined,
link: new URL(linkUrl, baseUrl).href,
category: categories,
guid,
id: guid,
- updated: updated ? timezone(parseDate(updated), +8) : undefined,
+ updated: updated ? timezone(parseDate(updated), 8) : undefined,
language,
};
diff --git a/lib/routes/szse/projectdynamic.tsx b/lib/routes/szse/projectdynamic.tsx
index 84d663902..f8efc94ff 100644
--- a/lib/routes/szse/projectdynamic.tsx
+++ b/lib/routes/szse/projectdynamic.tsx
@@ -131,7 +131,7 @@ async function handler(ctx) {
item.description = renderDescription(data, current);
- item.pubDate = timezone(parseDate(current.startTime, 'YYYY-MM-DD HH:mm:ss'), +8);
+ item.pubDate = timezone(parseDate(current.startTime, 'YYYY-MM-DD HH:mm:ss'), 8);
return item;
})
diff --git a/lib/routes/szse/rule.ts b/lib/routes/szse/rule.ts
index 2eae25a34..fb50c8dfc 100644
--- a/lib/routes/szse/rule.ts
+++ b/lib/routes/szse/rule.ts
@@ -51,7 +51,7 @@ export const handler = async (ctx) => {
item.title = title;
item.description = description;
- item.pubDate = item.pubDate ?? parseDate($$('div.time span').text());
+ item.pubDate ??= parseDate($$('div.time span').text());
item.author = $$('meta[name="author"]').prop('content');
item.content = {
html: description,
diff --git a/lib/routes/taiwannews/hot.ts b/lib/routes/taiwannews/hot.ts
index 812303326..8e70262d8 100644
--- a/lib/routes/taiwannews/hot.ts
+++ b/lib/routes/taiwannews/hot.ts
@@ -45,7 +45,7 @@ async function handler(ctx) {
return {
title: a.attr('title'),
link: new URL(a.attr('href'), baseUrl).href,
- pubDate: timezone(parseDate(item.find('.entry-date span').eq(1).text(), 'YYYY/MM/DD HH:mm'), +8),
+ pubDate: timezone(parseDate(item.find('.entry-date span').eq(1).text(), 'YYYY/MM/DD HH:mm'), 8),
};
})
.filter((item) => item.title);
diff --git a/lib/routes/taoguba/util.ts b/lib/routes/taoguba/util.ts
index 90f4e3070..f08131d9b 100644
--- a/lib/routes/taoguba/util.ts
+++ b/lib/routes/taoguba/util.ts
@@ -38,7 +38,7 @@ const renderPostDetail = async (item) =>
.text()
.match(/\d{4}-\d{2}-\d{2} \d{2}:\d{2}/)[0]
),
- +8
+ 8
);
item.category = content('.classify')
diff --git a/lib/routes/techflowpost/utils.ts b/lib/routes/techflowpost/utils.ts
index acaabc2f3..0380b035e 100644
--- a/lib/routes/techflowpost/utils.ts
+++ b/lib/routes/techflowpost/utils.ts
@@ -62,7 +62,7 @@ function getHeaders(referer: string, cookie = acwScV2Cookie) {
'accept-language': locale,
referer,
'user-agent': config.trueUA,
- ...(cookie ? { cookie } : {}),
+ ...(cookie && { cookie }),
};
}
diff --git a/lib/routes/telegram/channel.ts b/lib/routes/telegram/channel.ts
index 12b2cbe2b..094690c33 100644
--- a/lib/routes/telegram/channel.ts
+++ b/lib/routes/telegram/channel.ts
@@ -492,8 +492,12 @@ async function handler(ctx) {
height = (Number(aspectRatioStr) / 100) * width;
}
// Only set width/height when >32 to avoid invisible images.
- width > 32 && attrs.push(`width="${width}"`);
- height > 32 && attrs.push(`height="${height.toFixed(2).replace('.00', '')}"`);
+ if (width > 32) {
+ attrs.push(`width="${width}"`);
+ }
+ if (height > 32) {
+ attrs.push(`height="${height.toFixed(2).replace('.00', '')}"`);
+ }
tag_media += backgroundUrlSrc ? `
` : '';
}
if (tag_media) {
diff --git a/lib/routes/telegram/stories.ts b/lib/routes/telegram/stories.ts
index 2d4fa44ef..320a5e656 100644
--- a/lib/routes/telegram/stories.ts
+++ b/lib/routes/telegram/stories.ts
@@ -67,7 +67,8 @@ export const route: Route = {
function getMediaAreas(mediaAreas?: Api.TypeMediaArea[]) {
let description = '';
- for (const area of mediaAreas ?? []) {
+ const areas = mediaAreas ?? [];
+ for (const area of areas) {
if (area instanceof Api.MediaAreaChannelPost) {
// TODO: fetch area.msgId and display inline
} else if ((area instanceof Api.MediaAreaGeoPoint || area instanceof Api.MediaAreaVenue) && area.geo instanceof Api.GeoPoint) {
diff --git a/lib/routes/thecover/channel.ts b/lib/routes/thecover/channel.ts
index 039658fbb..16e81d265 100644
--- a/lib/routes/thecover/channel.ts
+++ b/lib/routes/thecover/channel.ts
@@ -73,7 +73,7 @@ async function handler(ctx) {
item.description = content('section.article-content').html();
const info = content('span', '.props-of-title');
item.author = info.eq(0).text();
- item.pubDate = timezone(parseDate(info.eq(1).text(), 'YYYY-MM-DD HH:mm'), +8);
+ item.pubDate = timezone(parseDate(info.eq(1).text(), 'YYYY-MM-DD HH:mm'), 8);
return item;
})
)
diff --git a/lib/routes/themoviedb/api-key.ts b/lib/routes/themoviedb/api-key.ts
index 3589105ce..d6fa65490 100644
--- a/lib/routes/themoviedb/api-key.ts
+++ b/lib/routes/themoviedb/api-key.ts
@@ -20,5 +20,4 @@ const KEYS = [
'09ad8ace66eec34302943272db0e8d2c',
];
-const keys = () => KEYS[Math.floor(Math.random() * KEYS.length)];
-export default keys;
+export const keys = () => KEYS[Math.floor(Math.random() * KEYS.length)];
diff --git a/lib/routes/themoviedb/collection.ts b/lib/routes/themoviedb/collection.ts
index cb1c0b651..7d63bd494 100644
--- a/lib/routes/themoviedb/collection.ts
+++ b/lib/routes/themoviedb/collection.ts
@@ -1,7 +1,7 @@
import type { Route } from '@/types';
import got from '@/utils/got';
-import apiKey from './api-key';
+import { keys as apiKey } from './api-key';
import { handleMovieItem } from './utils';
export const route: Route = {
diff --git a/lib/routes/themoviedb/episodes.ts b/lib/routes/themoviedb/episodes.ts
index 152c2bb0b..cedb8d407 100644
--- a/lib/routes/themoviedb/episodes.ts
+++ b/lib/routes/themoviedb/episodes.ts
@@ -2,7 +2,7 @@ import type { Route } from '@/types';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
-import apiKey from './api-key';
+import { keys as apiKey } from './api-key';
import { handleDescription } from './utils';
export const route: Route = {
diff --git a/lib/routes/themoviedb/seasons.ts b/lib/routes/themoviedb/seasons.ts
index f6bab793d..b70526e97 100644
--- a/lib/routes/themoviedb/seasons.ts
+++ b/lib/routes/themoviedb/seasons.ts
@@ -3,7 +3,7 @@ import { ViewType } from '@/types';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
-import apiKey from './api-key';
+import { keys as apiKey } from './api-key';
import { handleDescription } from './utils';
export const route: Route = {
diff --git a/lib/routes/themoviedb/sheet.ts b/lib/routes/themoviedb/sheet.ts
index f281dae51..23dfdd879 100644
--- a/lib/routes/themoviedb/sheet.ts
+++ b/lib/routes/themoviedb/sheet.ts
@@ -1,7 +1,7 @@
import type { Route } from '@/types';
import got from '@/utils/got';
-import apiKey from './api-key';
+import { keys as apiKey } from './api-key';
import { MEDIA_TYPE_TO_ITEM_HANDLE } from './utils';
const API_PATH = {
diff --git a/lib/routes/themoviedb/trending.ts b/lib/routes/themoviedb/trending.ts
index 0804486ed..bd14b5f88 100644
--- a/lib/routes/themoviedb/trending.ts
+++ b/lib/routes/themoviedb/trending.ts
@@ -1,7 +1,7 @@
import type { Route } from '@/types';
import got from '@/utils/got';
-import apiKey from './api-key';
+import { keys as apiKey } from './api-key';
import { MEDIA_TYPE_TO_ITEM_HANDLE } from './utils';
const MEDIA_TYPE_TO_TITLE = {
diff --git a/lib/routes/thepaper/factpaper.tsx b/lib/routes/thepaper/factpaper.tsx
index 5adbc298c..931e9abd5 100644
--- a/lib/routes/thepaper/factpaper.tsx
+++ b/lib/routes/thepaper/factpaper.tsx
@@ -53,7 +53,7 @@ async function handler(ctx) {
title: item.title,
guid: item.proveId,
link: `${rootUrl}/detail?id=${item.proveId}`,
- pubDate: timezone(parseDate(item.publishTime), +8),
+ pubDate: timezone(parseDate(item.publishTime), 8),
}));
items = await Promise.all(
diff --git a/lib/routes/thepaper/utils.tsx b/lib/routes/thepaper/utils.tsx
index 617cf2158..bf7c1794f 100644
--- a/lib/routes/thepaper/utils.tsx
+++ b/lib/routes/thepaper/utils.tsx
@@ -38,7 +38,7 @@ export default {
let description = contentDetail.content || contentDetail.summary || contentDetail.desc || '';
if (contentDetail.videos) {
- description = description + contentDetail.summary;
+ description += contentDetail.summary;
}
if (useOldMode) {
if (contentDetail.videos) {
diff --git a/lib/routes/tingshuitz/shenzhen.tsx b/lib/routes/tingshuitz/shenzhen.tsx
index 735f2355f..478577d10 100644
--- a/lib/routes/tingshuitz/shenzhen.tsx
+++ b/lib/routes/tingshuitz/shenzhen.tsx
@@ -55,7 +55,7 @@ async function handler() {
>
),
- pubDate: timezone(parseDate(item.createdOn, 'YYYY-MM-DD HH:mm:ss'), +8),
+ pubDate: timezone(parseDate(item.createdOn, 'YYYY-MM-DD HH:mm:ss'), 8),
link: 'https://szgk.sz-water.com.cn/wechat_web/Water_stop.html',
guid: `${item.position}${item.stopStartTime}`,
})),
diff --git a/lib/routes/tju/cic/index.ts b/lib/routes/tju/cic/index.ts
index 16dee7024..4c5f87516 100644
--- a/lib/routes/tju/cic/index.ts
+++ b/lib/routes/tju/cic/index.ts
@@ -107,7 +107,7 @@ async function handler(ctx) {
try {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
- item.pubDate = timezone(parseDate(content('.news_info > span').first().text(), 'YYYY年MM月DD日 HH:mm'), +8);
+ item.pubDate = timezone(parseDate(content('.news_info > span').first().text(), 'YYYY年MM月DD日 HH:mm'), 8);
content('.news_tit').remove();
content('.news_info').remove();
item.description = content('.con_news_body > div').html();
diff --git a/lib/routes/tju/news/index.ts b/lib/routes/tju/news/index.ts
index 8a7c60f78..18062668f 100644
--- a/lib/routes/tju/news/index.ts
+++ b/lib/routes/tju/news/index.ts
@@ -128,7 +128,7 @@ async function handler(ctx) {
.match(/\d{4}-\d{2}-\d{2}/)[0],
'YYYY-MM-DD'
),
- +8
+ 8
);
item.description = content('.v_news_content').html();
} catch {
diff --git a/lib/routes/tju/oaa/index.ts b/lib/routes/tju/oaa/index.ts
index 320b83e9f..34d4692ea 100644
--- a/lib/routes/tju/oaa/index.ts
+++ b/lib/routes/tju/oaa/index.ts
@@ -97,7 +97,7 @@ async function handler(ctx) {
return {
title: $('h2', item).text(),
link: type === 'in-site' ? oaa_base_url + href : href,
- pubDate: timezone(parseDate($('.fl_01_r_time', item).text(), 'DDYYYY-MM'), +8),
+ pubDate: timezone(parseDate($('.fl_01_r_time', item).text(), 'DDYYYY-MM'), 8),
type,
};
});
diff --git a/lib/routes/tju/yzb/index.ts b/lib/routes/tju/yzb/index.ts
index 60fea8dd9..6bd7d6b8a 100644
--- a/lib/routes/tju/yzb/index.ts
+++ b/lib/routes/tju/yzb/index.ts
@@ -104,7 +104,7 @@ async function handler(ctx) {
return {
title: $('td > a', item).text(),
link: type === 'in-site' ? yzb_base_url + path + href : href,
- pubDate: timezone(parseDate($('.font_10_time', item).text().slice(2, -2), 'YYYY-MM-DD'), +8),
+ pubDate: timezone(parseDate($('.font_10_time', item).text().slice(2, -2), 'YYYY-MM-DD'), 8),
type,
};
});
diff --git a/lib/routes/toodaylab/index.ts b/lib/routes/toodaylab/index.ts
index 5d6b01a86..5c99f49c1 100644
--- a/lib/routes/toodaylab/index.ts
+++ b/lib/routes/toodaylab/index.ts
@@ -58,7 +58,7 @@ async function handler(ctx) {
link: new URL(a.prop('href'), rootUrl).href,
description: item.find('p.excerpt').html(),
author: item.find('div.left-infos p a').text().trim(),
- pubDate: timezone(/[年日月]/.test(pubDate) ? parseDate(pubDate, ['YYYY年M月D日 HH:mm', 'M月D日 HH:mm']) : parseRelativeDate(pubDate), +8),
+ pubDate: timezone(/[年日月]/.test(pubDate) ? parseDate(pubDate, ['YYYY年M月D日 HH:mm', 'M月D日 HH:mm']) : parseRelativeDate(pubDate), 8),
};
});
@@ -82,7 +82,7 @@ async function handler(ctx) {
.slice(1)
.toArray()
.map((c) => content(c).text().replace(/#/, ''));
- item.pubDate = item.pubDate ?? timezone(/[年日月]/.test(pubDate) ? parseDate(pubDate, ['YYYY年M月D日 HH:mm', 'M月D日 HH:mm']) : parseRelativeDate(pubDate), +8);
+ item.pubDate ??= timezone(/[年日月]/.test(pubDate) ? parseDate(pubDate, ['YYYY年M月D日 HH:mm', 'M月D日 HH:mm']) : parseRelativeDate(pubDate), 8);
item.upvotes = content('#like_count').text() ? Number(content('#like_count').text()) : 0;
item.comments = Number(content('div.right-infos a').first().text()) || 0;
diff --git a/lib/routes/topys/index.ts b/lib/routes/topys/index.ts
index a956f3903..00906f621 100644
--- a/lib/routes/topys/index.ts
+++ b/lib/routes/topys/index.ts
@@ -79,7 +79,7 @@ async function handler(ctx) {
const content = load(detailResponse.data);
item.description = content('.article-content').html();
- item.author = item.author ?? content('.author-name p').first().text();
+ item.author ??= content('.author-name p').first().text();
return item;
})
diff --git a/lib/routes/toutiao/a-bogus.ts b/lib/routes/toutiao/a-bogus.ts
index 673574802..d243420cc 100644
--- a/lib/routes/toutiao/a-bogus.ts
+++ b/lib/routes/toutiao/a-bogus.ts
@@ -1,4 +1,4 @@
-// oxlint-disable no-undef unicorn-js/no-this-outside-of-class
+// oxlint-disable no-undef unicorn-js/no-this-outside-of-class unicorn-js/no-return-array-push
// oxlint-disable unicorn/prefer-spread
// oxlint-disable unicorn/prefer-math-trunc
// @ts-nocheck
@@ -275,7 +275,7 @@ function result_encrypt(long_str: string, num: 's0' | 's1' | 's2' | 's3' | 's4')
}
function get_long_int(round, long_str) {
- round = round * 3;
+ round *= 3;
return (long_str.codePointAt(round) << 16) | (long_str.codePointAt(round + 1) << 8) | long_str.codePointAt(round + 2);
}
diff --git a/lib/routes/tqyb/sncsyjxh.tsx b/lib/routes/tqyb/sncsyjxh.tsx
index 6796c63e4..b3c7e206a 100644
--- a/lib/routes/tqyb/sncsyjxh.tsx
+++ b/lib/routes/tqyb/sncsyjxh.tsx
@@ -56,8 +56,8 @@ async function handler() {
发布时间:{item.datetime}
>
),
- pubDate: timezone(parseDate(item.datetime, 'YYYY年MM月DD日 HH:mm'), +8),
- guid: timezone(parseDate(item.datetime, 'YYYY年MM月DD日 HH:mm'), +8) + item.cname + item.sigtypename,
+ pubDate: timezone(parseDate(item.datetime, 'YYYY年MM月DD日 HH:mm'), 8),
+ guid: timezone(parseDate(item.datetime, 'YYYY年MM月DD日 HH:mm'), 8) + item.cname + item.sigtypename,
}));
return {
diff --git a/lib/routes/tradingview/desktop.ts b/lib/routes/tradingview/desktop.ts
index 54d6778d0..09659f77e 100644
--- a/lib/routes/tradingview/desktop.ts
+++ b/lib/routes/tradingview/desktop.ts
@@ -65,7 +65,7 @@ async function handler(ctx) {
.toArray()
.map((c) => $(c).text()),
guid: `tradingview-desktop#${title.split(/versions?\s/).pop()}`,
- pubDate: timezone(parseDate(title.split(/\./, 1)[0], 'MMMM D, YYYY'), +8),
+ pubDate: timezone(parseDate(title.split(/\./, 1)[0], 'MMMM D, YYYY'), 8),
};
});
diff --git a/lib/routes/trow/portal.ts b/lib/routes/trow/portal.ts
index d01921d3d..24c431a4b 100644
--- a/lib/routes/trow/portal.ts
+++ b/lib/routes/trow/portal.ts
@@ -61,7 +61,7 @@ async function handler() {
description: item.find('.portal_news_content .row18').html(),
link: item.find('.maintitle p:nth-child(2) > a').attr('href'),
author: item.find('.postdetails a').text(),
- pubDate: timezone(parseDate(dateraw.slice(3), 'YYYY-MM-DD, HH:mm'), +8),
+ pubDate: timezone(parseDate(dateraw.slice(3), 'YYYY-MM-DD, HH:mm'), 8),
};
}),
};
diff --git a/lib/routes/ttv/index.ts b/lib/routes/ttv/index.ts
index cab774a2a..a808d7056 100644
--- a/lib/routes/ttv/index.ts
+++ b/lib/routes/ttv/index.ts
@@ -55,7 +55,7 @@ async function handler(ctx) {
const content = load(detailResponse.data);
item.title = content('title').text();
- item.pubDate = timezone(parseDate(content('meta[property="article:published_time"]').attr('content')), +8);
+ item.pubDate = timezone(parseDate(content('meta[property="article:published_time"]').attr('content')), 8);
item.category = content('div.article-body ul.tag')
.find('a')
.toArray()
diff --git a/lib/routes/tumblr/utils.ts b/lib/routes/tumblr/utils.ts
index 50c4eeb68..cc7a6896a 100644
--- a/lib/routes/tumblr/utils.ts
+++ b/lib/routes/tumblr/utils.ts
@@ -47,11 +47,13 @@ const processPost: (post: any) => DataItem = (post) => {
description += `${post.blog_name} answers:
`;
description += post.answer;
break;
- case 'photo':
- for (const photo of post.photos ?? []) {
+ case 'photo': {
+ const photos = post.photos ?? [];
+ for (const photo of photos) {
description += `
`;
}
break;
+ }
case 'link':
description = post.url;
break;
diff --git a/lib/routes/tver/series.ts b/lib/routes/tver/series.ts
index 23629b4ee..29c8bd41d 100644
--- a/lib/routes/tver/series.ts
+++ b/lib/routes/tver/series.ts
@@ -77,7 +77,7 @@ async function handler(ctx: Context): Promise {
.map((i) => {
const rawPubDate = i.content.broadcastDateLabel;
const cleanedPubDate = rawPubDate.replaceAll(/\(.*?\)|放送分/g, '').trim();
- const parsedPubDate = timezone(parseDate(cleanedPubDate, 'M月D日'), +9).toDateString();
+ const parsedPubDate = timezone(parseDate(cleanedPubDate, 'M月D日'), 9).toDateString();
return {
title: i.content.title,
diff --git a/lib/routes/twitter/api/developer-api/api.ts b/lib/routes/twitter/api/developer-api/api.ts
index e7de3f2ae..420f356ce 100644
--- a/lib/routes/twitter/api/developer-api/api.ts
+++ b/lib/routes/twitter/api/developer-api/api.ts
@@ -166,7 +166,8 @@ const mapTweetToLegacy = (tweet: Record, includes: Record {
allowEmpty: true,
};
};
+// TODO: missing route export
export default handler;
diff --git a/lib/routes/twitter/api/index.ts b/lib/routes/twitter/api/index.ts
index 2e8151c4e..58200fa0d 100644
--- a/lib/routes/twitter/api/index.ts
+++ b/lib/routes/twitter/api/index.ts
@@ -39,9 +39,7 @@ let api: {
getHomeLatestTimeline: () => null,
};
-if (enableThirdPartyApi) {
- api = webApi;
-} else if (enableWebApi) {
+if (enableThirdPartyApi || enableWebApi) {
api = webApi;
} else if (enableDeveloperApi) {
api = devApi;
diff --git a/lib/routes/twitter/api/mobile-api/api.ts b/lib/routes/twitter/api/mobile-api/api.ts
index de2e24e52..740971f16 100644
--- a/lib/routes/twitter/api/mobile-api/api.ts
+++ b/lib/routes/twitter/api/mobile-api/api.ts
@@ -143,42 +143,44 @@ function gatherLegacyFromData(entries, filterNested?, userId?) {
}
}
for (const entry of filteredEntries) {
- if (entry.entryId) {
- const content = entry.content || entry.item;
- let tweet = content?.content?.tweetResult?.result || content?.itemContent?.tweet_results?.result;
- if (tweet && tweet.tweet) {
- tweet = tweet.tweet;
- }
- if (tweet) {
- const retweet = tweet.legacy?.retweeted_status_result?.result;
- for (const t of [tweet, retweet]) {
- if (!t?.legacy) {
- continue;
- }
- t.legacy.user = t.core?.user_result?.result?.legacy || t.core?.user_results?.result?.legacy;
- t.legacy.id_str = t.rest_id; // avoid falling back to conversation_id_str elsewhere
- const quote = t.quoted_status_result?.result;
- if (quote) {
- t.legacy.quoted_status = quote.legacy;
- t.legacy.quoted_status.user = quote.core.user_result?.result?.legacy || quote.core.user_results?.result?.legacy;
- }
- if (t.note_tweet) {
- const tmp = t.note_tweet.note_tweet_results.result;
- t.legacy.entities.hashtags = tmp.entity_set.hashtags;
- t.legacy.entities.symbols = tmp.entity_set.symbols;
- t.legacy.entities.urls = tmp.entity_set.urls;
- t.legacy.entities.user_mentions = tmp.entity_set.user_mentions;
- t.legacy.full_text = tmp.text;
- }
+ if (!entry.entryId) {
+ continue;
+ }
+
+ const content = entry.content || entry.item;
+ let tweet = content?.content?.tweetResult?.result || content?.itemContent?.tweet_results?.result;
+ if (tweet && tweet.tweet) {
+ tweet = tweet.tweet;
+ }
+ if (tweet) {
+ const retweet = tweet.legacy?.retweeted_status_result?.result;
+ for (const t of [tweet, retweet]) {
+ if (!t?.legacy) {
+ continue;
}
- const legacy = tweet.legacy;
- if (legacy) {
- if (retweet) {
- legacy.retweeted_status = retweet.legacy;
- }
- if (userId === undefined || legacy.user_id_str === userId + '') {
- tweets.push(legacy);
- }
+ t.legacy.user = t.core?.user_result?.result?.legacy || t.core?.user_results?.result?.legacy;
+ t.legacy.id_str = t.rest_id; // avoid falling back to conversation_id_str elsewhere
+ const quote = t.quoted_status_result?.result;
+ if (quote) {
+ t.legacy.quoted_status = quote.legacy;
+ t.legacy.quoted_status.user = quote.core.user_result?.result?.legacy || quote.core.user_results?.result?.legacy;
+ }
+ if (t.note_tweet) {
+ const tmp = t.note_tweet.note_tweet_results.result;
+ t.legacy.entities.hashtags = tmp.entity_set.hashtags;
+ t.legacy.entities.symbols = tmp.entity_set.symbols;
+ t.legacy.entities.urls = tmp.entity_set.urls;
+ t.legacy.entities.user_mentions = tmp.entity_set.user_mentions;
+ t.legacy.full_text = tmp.text;
+ }
+ }
+ const legacy = tweet.legacy;
+ if (legacy) {
+ if (retweet) {
+ legacy.retweeted_status = retweet.legacy;
+ }
+ if (userId === undefined || legacy.user_id_str === userId + '') {
+ tweets.push(legacy);
}
}
}
diff --git a/lib/routes/twitter/api/mobile-api/login.ts b/lib/routes/twitter/api/mobile-api/login.ts
index 47d8a79aa..c7261edcc 100644
--- a/lib/routes/twitter/api/mobile-api/login.ts
+++ b/lib/routes/twitter/api/mobile-api/login.ts
@@ -198,10 +198,10 @@ async function login({ username, password, authenticationSecret, phoneOrEmail })
},
60 * 60 * 24 * 30, // 30 days
false
- )) as null | {
+ )) as {
oauth_token: string;
oauth_token_secret: string;
- };
+ } | null;
}
export default login;
diff --git a/lib/routes/twitter/api/web-api/utils.ts b/lib/routes/twitter/api/web-api/utils.ts
index 8d7624fb2..1f5a70d5c 100644
--- a/lib/routes/twitter/api/web-api/utils.ts
+++ b/lib/routes/twitter/api/web-api/utils.ts
@@ -99,11 +99,11 @@ export const twitterGot = async (
});
}
let dispatchers:
- | undefined
| {
jar: CookieJar;
agent: CookieAgent | ProxyAgent;
- };
+ }
+ | undefined;
if (cookie) {
logger.debug(`twitter debug: got twitter cookie for token ${auth?.token}`);
if (typeof cookie === 'string') {
@@ -324,9 +324,7 @@ export function gatherLegacyFromData(entries: any[], filterNested?: string[], us
for (const entry of entries) {
const entryId = entry.entryId;
if (entryId) {
- if (entryId.startsWith('tweet-')) {
- filteredEntries.push(entry);
- } else if (entryId.startsWith('profile-grid-0-tweet-')) {
+ if (entryId.startsWith('tweet-') || entryId.startsWith('profile-grid-0-tweet-')) {
filteredEntries.push(entry);
}
if (filterNested && filterNested.some((f) => entryId.startsWith(f))) {
@@ -335,64 +333,66 @@ export function gatherLegacyFromData(entries: any[], filterNested?: string[], us
}
}
for (const entry of filteredEntries) {
- if (entry.entryId) {
- const content = entry.content || entry.item;
- let tweet = content?.content?.tweetResult?.result || content?.itemContent?.tweet_results?.result;
- // Handle subscriber-only preview posts (must check before tweet.tweet reassignment)
- if (tweet?.__typename === 'TweetPreviewDisplay') {
- const preview = tweet.tweet;
- if (preview?.rest_id) {
- const userResult = preview.core?.user_results?.result;
- const fakeLegacy: any = {
- id_str: preview.rest_id,
- full_text: `[Subscribers Only] ${preview.text ?? ''}`,
- created_at: preview.created_at ?? '',
- entities: { urls: [], hashtags: [], symbols: [], user_mentions: [] },
- user_id_str: userResult?.rest_id ?? '',
- favorite_count: preview.favorite_count ?? 0,
- reply_count: preview.reply_count ?? 0,
- retweet_count: preview.retweet_count ?? 0,
- };
- hydrateLegacyUser(fakeLegacy, { core: preview.core, rest_id: preview.rest_id });
- if (userId === undefined || fakeLegacy.user_id_str === userId + '') {
- tweets.push(fakeLegacy);
- }
+ if (!entry.entryId) {
+ continue;
+ }
+
+ const content = entry.content || entry.item;
+ let tweet = content?.content?.tweetResult?.result || content?.itemContent?.tweet_results?.result;
+ // Handle subscriber-only preview posts (must check before tweet.tweet reassignment)
+ if (tweet?.__typename === 'TweetPreviewDisplay') {
+ const preview = tweet.tweet;
+ if (preview?.rest_id) {
+ const userResult = preview.core?.user_results?.result;
+ const fakeLegacy: any = {
+ id_str: preview.rest_id,
+ full_text: `[Subscribers Only] ${preview.text ?? ''}`,
+ created_at: preview.created_at ?? '',
+ entities: { urls: [], hashtags: [], symbols: [], user_mentions: [] },
+ user_id_str: userResult?.rest_id ?? '',
+ favorite_count: preview.favorite_count ?? 0,
+ reply_count: preview.reply_count ?? 0,
+ retweet_count: preview.retweet_count ?? 0,
+ };
+ hydrateLegacyUser(fakeLegacy, { core: preview.core, rest_id: preview.rest_id });
+ if (userId === undefined || fakeLegacy.user_id_str === userId + '') {
+ tweets.push(fakeLegacy);
}
- continue;
}
- if (tweet && tweet.tweet) {
- tweet = tweet.tweet;
- }
- if (tweet) {
- const retweet = tweet.legacy?.retweeted_status_result?.result;
- for (const t of [tweet, retweet]) {
- if (!t?.legacy) {
- continue;
- }
- hydrateLegacyUser(t.legacy, t);
- t.legacy.id_str = t.rest_id; // avoid falling back to conversation_id_str elsewhere
- const quote = t.quoted_status_result?.result?.tweet || t.quoted_status_result?.result;
- if (quote?.legacy) {
- t.legacy.quoted_status = quote.legacy;
- hydrateLegacyUser(t.legacy.quoted_status, quote);
- }
- if (t.note_tweet) {
- const tmp = t.note_tweet.note_tweet_results.result;
- t.legacy.entities.hashtags = tmp.entity_set.hashtags;
- t.legacy.entities.symbols = tmp.entity_set.symbols;
- t.legacy.entities.urls = tmp.entity_set.urls;
- t.legacy.entities.user_mentions = tmp.entity_set.user_mentions;
- t.legacy.full_text = tmp.text;
- }
+ continue;
+ }
+ if (tweet && tweet.tweet) {
+ tweet = tweet.tweet;
+ }
+ if (tweet) {
+ const retweet = tweet.legacy?.retweeted_status_result?.result;
+ for (const t of [tweet, retweet]) {
+ if (!t?.legacy) {
+ continue;
}
- const legacy = tweet.legacy;
- if (legacy) {
- if (retweet) {
- legacy.retweeted_status = retweet.legacy;
- }
- if (userId === undefined || legacy.user_id_str === userId + '') {
- tweets.push(legacy);
- }
+ hydrateLegacyUser(t.legacy, t);
+ t.legacy.id_str = t.rest_id; // avoid falling back to conversation_id_str elsewhere
+ const quote = t.quoted_status_result?.result?.tweet || t.quoted_status_result?.result;
+ if (quote?.legacy) {
+ t.legacy.quoted_status = quote.legacy;
+ hydrateLegacyUser(t.legacy.quoted_status, quote);
+ }
+ if (t.note_tweet) {
+ const tmp = t.note_tweet.note_tweet_results.result;
+ t.legacy.entities.hashtags = tmp.entity_set.hashtags;
+ t.legacy.entities.symbols = tmp.entity_set.symbols;
+ t.legacy.entities.urls = tmp.entity_set.urls;
+ t.legacy.entities.user_mentions = tmp.entity_set.user_mentions;
+ t.legacy.full_text = tmp.text;
+ }
+ }
+ const legacy = tweet.legacy;
+ if (legacy) {
+ if (retweet) {
+ legacy.retweeted_status = retweet.legacy;
+ }
+ if (userId === undefined || legacy.user_id_str === userId + '') {
+ tweets.push(legacy);
}
}
}
diff --git a/lib/routes/twitter/utils.ts b/lib/routes/twitter/utils.ts
index 8d18e81d5..609bd0c00 100644
--- a/lib/routes/twitter/utils.ts
+++ b/lib/routes/twitter/utils.ts
@@ -212,7 +212,7 @@ const ProcessFeed = (ctx, { data = [] }, params = {}) => {
}
const originalItem = item;
item = item.retweeted_status || item;
- item.full_text = item.full_text || item.text;
+ item.full_text ||= item.text;
item.full_text = formatText(item);
const img = formatMedia(item);
let picsPrefix = generatePicsPrefix(item);
@@ -224,7 +224,7 @@ const ProcessFeed = (ctx, { data = [] }, params = {}) => {
const quoteData = item.quoted_status;
if (quoteData?.user) {
- quoteData.full_text = quoteData.full_text || quoteData.text;
+ quoteData.full_text ||= quoteData.text;
const author = quoteData.user;
if (!readable) {
quote += quoteSeparator;
diff --git a/lib/routes/txrjy/fornumtopic.tsx b/lib/routes/txrjy/fornumtopic.tsx
index d3dcf2422..3f43db7c4 100644
--- a/lib/routes/txrjy/fornumtopic.tsx
+++ b/lib/routes/txrjy/fornumtopic.tsx
@@ -48,7 +48,7 @@ async function handler(ctx) {
title: $(item).find('td.title2').text(),
link: new URL($(item).find('td.title2 > a').attr('href'), rootUrl).href,
author: $(item).find('td.author').text(),
- pubDate: timezone(parseDate($(item).find('td.dateline').text(), 'YYYY-M-D HH:mm'), +8),
+ pubDate: timezone(parseDate($(item).find('td.dateline').text(), 'YYYY-M-D HH:mm'), 8),
category: $(item).find('td.forum').text(),
}))
.filter((item) => item.title);
diff --git a/lib/routes/u9a9/index.ts b/lib/routes/u9a9/index.ts
index dbf2ea70b..1700eb8ca 100644
--- a/lib/routes/u9a9/index.ts
+++ b/lib/routes/u9a9/index.ts
@@ -53,7 +53,7 @@ async function handler(ctx) {
return {
title: a.attr('title'),
link: `${baseUrl}${a.attr('href')}`,
- pubDate: timezone(parseDate(item.find('td').eq(4).text()), +8),
+ pubDate: timezone(parseDate(item.find('td').eq(4).text()), 8),
enclosure_url: item.find('td').eq(2).find('a').eq(1).attr('href'),
enclosure_length: Number.parseInt(size * (unit === 'GB' ? 1024 * 1024 * 1024 : 1024 * 1024)),
diff --git a/lib/routes/udn/breaking-news.tsx b/lib/routes/udn/breaking-news.tsx
index e8fec3bd5..85e370b0c 100644
--- a/lib/routes/udn/breaking-news.tsx
+++ b/lib/routes/udn/breaking-news.tsx
@@ -99,7 +99,7 @@ async function handler(ctx) {
title: item.title,
author: [{ name: $('.article-content__author').text().match('中央社')?.at(0) }, { name: data.publisher.name.match('轉角國際 udn Global')?.at(0) }, data.author].filter((e) => e.name),
description,
- pubDate: timezone(parseDate(item.time.date, 'YYYY-MM-DD HH:mm'), +8),
+ pubDate: timezone(parseDate(item.time.date, 'YYYY-MM-DD HH:mm'), 8),
category: [data.articleSection, vip ? $('.article-head li.breadcrumb__item:last > b').text() : $("meta[name='subsection']").attr('content'), ...data.keywords.split(',')],
link,
};
diff --git a/lib/routes/udn/global/index.ts b/lib/routes/udn/global/index.ts
index f69887713..cdf67185e 100644
--- a/lib/routes/udn/global/index.ts
+++ b/lib/routes/udn/global/index.ts
@@ -94,7 +94,7 @@ async function handler(ctx) {
const content = load(detailResponse.data);
item.author = content('.article-content__authors-name').first().text().trim();
- item.pubDate = timezone(parseDate(content('meta[property="article:published_time"]').attr('content')), +8);
+ item.pubDate = timezone(parseDate(content('meta[property="article:published_time"]').attr('content')), 8);
const mainImage = content('.article-content__focus').html();
const articleBodyHtml = content('.article-content__editor')
diff --git a/lib/routes/udn/global/tag.ts b/lib/routes/udn/global/tag.ts
index a15b2f8fd..1e338abd3 100644
--- a/lib/routes/udn/global/tag.ts
+++ b/lib/routes/udn/global/tag.ts
@@ -46,7 +46,7 @@ async function handler(ctx) {
let items = response.data.lists.map((item) => ({
title: item.title,
author: item.author?.title,
- pubDate: timezone(parseDate(item.time?.dateTime), +8),
+ pubDate: timezone(parseDate(item.time?.dateTime), 8),
link: item.url,
category: item.hash?.map((h) => h.title),
}));
diff --git a/lib/routes/uestc/bbs.ts b/lib/routes/uestc/bbs.ts
index b32c48334..2cd026e09 100644
--- a/lib/routes/uestc/bbs.ts
+++ b/lib/routes/uestc/bbs.ts
@@ -80,7 +80,7 @@ export const route: Route = {
author: item.author,
category: item.label,
img: item.icon,
- pubDate: timezone(parseDate(item.dateline), +8),
+ pubDate: timezone(parseDate(item.dateline), 8),
description: item.description,
};
})
diff --git a/lib/routes/uestc/gr.ts b/lib/routes/uestc/gr.ts
index a73de7bee..4aae2298f 100644
--- a/lib/routes/uestc/gr.ts
+++ b/lib/routes/uestc/gr.ts
@@ -84,7 +84,7 @@ async function handler(ctx: Context): Promise {
return {
title: newsTitle,
link: newsLink,
- pubDate: match ? timezone(parseDate(match[1]), +8) : null,
+ pubDate: match ? timezone(parseDate(match[1]), 8) : null,
description: content('div.content').html(),
};
});
diff --git a/lib/routes/uestc/jwc.ts b/lib/routes/uestc/jwc.ts
index 3facfa2ab..baf781700 100644
--- a/lib/routes/uestc/jwc.ts
+++ b/lib/routes/uestc/jwc.ts
@@ -85,7 +85,7 @@ async function handler(ctx: Context): Promise {
return {
title: newsTitle,
link: newsLink,
- pubDate: match ? timezone(parseDate(match[1]), +8) : null,
+ pubDate: match ? timezone(parseDate(match[1]), 8) : null,
description: content('div.NewText').html(),
};
});
diff --git a/lib/routes/uestc/scse.ts b/lib/routes/uestc/scse.ts
index f1b581d24..ef65aaa03 100644
--- a/lib/routes/uestc/scse.ts
+++ b/lib/routes/uestc/scse.ts
@@ -94,10 +94,12 @@ async function handler() {
let prefix = '【其他】';
for (const code in prefixes) {
- if (newsLink.search('info/' + code) !== -1) {
- prefix = prefixes[code];
- break;
+ if (newsLink.search('info/' + code) === -1) {
+ continue;
}
+
+ prefix = prefixes[code];
+ break;
}
newsTitle = prefix + newsTitle;
diff --git a/lib/routes/upc/jwc.ts b/lib/routes/upc/jwc.ts
index a69e5da01..f0c270266 100644
--- a/lib/routes/upc/jwc.ts
+++ b/lib/routes/upc/jwc.ts
@@ -30,7 +30,7 @@ const handler = async (ctx) => {
return {
title: a.text(),
link: linkStr,
- pubDate: timezone(parseDate(item.find('.news_meta').text()), +8), // 添加发布日期查询
+ pubDate: timezone(parseDate(item.find('.news_meta').text()), 8), // 添加发布日期查询
};
});
diff --git a/lib/routes/uptimerobot/rss.tsx b/lib/routes/uptimerobot/rss.tsx
index 13332e5cf..ded0e77c9 100644
--- a/lib/routes/uptimerobot/rss.tsx
+++ b/lib/routes/uptimerobot/rss.tsx
@@ -117,7 +117,7 @@ async function handler(ctx) {
}
const duration = item['details:duration'];
- const monitor = (monitors[monitorName] = monitors[monitorName] || new Monitor(monitorName));
+ const monitor = (monitors[monitorName] ||= new Monitor(monitorName));
if (status === 'UP') {
monitor.up(duration);
diff --git a/lib/routes/ustc/eeis.ts b/lib/routes/ustc/eeis.ts
index 204f3a647..3e44fbb35 100644
--- a/lib/routes/ustc/eeis.ts
+++ b/lib/routes/ustc/eeis.ts
@@ -60,7 +60,7 @@ async function handler(ctx) {
const title = item.find('h4 > a').eq(1).attr('title').trim();
let link = item.find('h4 > a').attr('href');
link = link.startsWith('/') ? host + link : link;
- const pubDate = timezone(parseDate(item.find('.post-date > time').text().replace('发布时间:', ''), 'YYYY-MM-DD'), +8);
+ const pubDate = timezone(parseDate(item.find('.post-date > time').text().replace('发布时间:', ''), 'YYYY-MM-DD'), 8);
return {
title,
pubDate,
diff --git a/lib/routes/ustc/gs.ts b/lib/routes/ustc/gs.ts
index 82a44f767..b96cbbf63 100644
--- a/lib/routes/ustc/gs.ts
+++ b/lib/routes/ustc/gs.ts
@@ -59,7 +59,7 @@ async function handler(ctx) {
item = $(item);
const title = item.find('a').text().trim();
const link = item.find('a').attr('href').startsWith('/article') ? host + item.find('a').attr('href') : item.find('a').attr('href');
- const pubDate = timezone(parseDate(item.find('time').text(), 'YYYY-MM-DD'), +8);
+ const pubDate = timezone(parseDate(item.find('time').text(), 'YYYY-MM-DD'), 8);
return {
title,
pubDate,
diff --git a/lib/routes/ustc/index.ts b/lib/routes/ustc/index.ts
index f17cff09a..248ff66b4 100644
--- a/lib/routes/ustc/index.ts
+++ b/lib/routes/ustc/index.ts
@@ -77,7 +77,7 @@ async function handler(ctx) {
const info = {
title: $(child[1]).find('a').attr('title'),
link: $(child[1]).find('a').attr('href').startsWith('../') ? new URL($(child[1]).find('a').attr('href'), notice_type[type].url).href : $(child[1]).find('a').attr('href'),
- pubDate: timezone(parseDate($(child[2]).text(), 'YYYY-MM-DD'), +8),
+ pubDate: timezone(parseDate($(child[2]).text(), 'YYYY-MM-DD'), 8),
};
return info;
});
diff --git a/lib/routes/ustc/jwc.ts b/lib/routes/ustc/jwc.ts
index 168c6adb9..40dcb5b4a 100644
--- a/lib/routes/ustc/jwc.ts
+++ b/lib/routes/ustc/jwc.ts
@@ -57,7 +57,7 @@ async function handler(ctx) {
const info = {
title: type === '' ? $(child[0]).find('a').text() + ' - ' + $(child[1]).find('a').text() : $(child[0]).find('a').text(),
link: type === '' ? $(child[1]).find('a').attr('href') : $(child[0]).find('a').attr('href'),
- pubDate: timezone(parseDate($(element).find('.date').text().trim(), 'YYYY-MM-DD'), +8),
+ pubDate: timezone(parseDate($(element).find('.date').text().trim(), 'YYYY-MM-DD'), 8),
};
return info;
});
@@ -71,7 +71,7 @@ async function handler(ctx) {
const $ = load(response.data);
// www.teach ?? pms.cmet ?? news
item.description = $('main[class=single]').html() ?? $('.card-footer').html() ?? $('.v_news_content').html();
- item.pubDate = $('li[class=meta-date]').text() ? timezone(parseDate($('li[class=meta-date]').text(), 'YYYY-MM-DD HH:mm'), +8) : item.pubDate;
+ item.pubDate = $('li[class=meta-date]').text() ? timezone(parseDate($('li[class=meta-date]').text(), 'YYYY-MM-DD HH:mm'), 8) : item.pubDate;
return item;
})
)
diff --git a/lib/routes/ustc/sist.ts b/lib/routes/ustc/sist.ts
index 700f7585d..759ce91d1 100644
--- a/lib/routes/ustc/sist.ts
+++ b/lib/routes/ustc/sist.ts
@@ -60,7 +60,7 @@ async function handler(ctx) {
const title = item.find('.card-title > a').attr('title').trim();
let link = item.find('.card-title > a').attr('href');
link = link.startsWith('/') ? host + link : link;
- const pubDate = timezone(parseDate(item.find('time').text().replace('发布时间:', ''), 'YYYY-MM-DD'), +8);
+ const pubDate = timezone(parseDate(item.find('time').text().replace('发布时间:', ''), 'YYYY-MM-DD'), 8);
return {
title,
pubDate,
diff --git a/lib/routes/usts/jwch.ts b/lib/routes/usts/jwch.ts
index 744be4d9e..62bccf666 100644
--- a/lib/routes/usts/jwch.ts
+++ b/lib/routes/usts/jwch.ts
@@ -62,7 +62,7 @@ async function handler(ctx) {
item.description = content('div#vsb_content').html();
item.author = author;
- item.pubDate = timezone(parseDate(pubDate), +8);
+ item.pubDate = timezone(parseDate(pubDate), 8);
return item;
})
diff --git a/lib/routes/utgd/utils.tsx b/lib/routes/utgd/utils.tsx
index 94fb3f6ad..c69a7890a 100644
--- a/lib/routes/utgd/utils.tsx
+++ b/lib/routes/utgd/utils.tsx
@@ -20,7 +20,7 @@ export const parseResult = (results, limit) =>
title: item.title,
link: `${rootUrl}/article/${item.id}`,
author: item.article_author_displayname,
- pubDate: timezone(parseDate(item.article_published_time), +8),
+ pubDate: timezone(parseDate(item.article_published_time), 8),
category: item.article_category.map((c) => c.category_name),
}));
diff --git a/lib/routes/visionias/utils.ts b/lib/routes/visionias/utils.ts
index 9c1eb5f55..470745697 100644
--- a/lib/routes/visionias/utils.ts
+++ b/lib/routes/visionias/utils.ts
@@ -99,7 +99,7 @@ export async function extractNews(item, selector) {
function extractArticle(articleDiv, selectorString: string = 'div.ck-content') {
const $ = load(articleDiv, null, false);
const articleDiv$ = $(articleDiv);
- const articleContent = articleDiv$.find(String(selectorString));
+ const articleContent = articleDiv$.find(selectorString);
articleContent.find('figure').each((_, element) => {
$(element).css('width', '');
});
diff --git a/lib/routes/washingtonpost/app.tsx b/lib/routes/washingtonpost/app.tsx
index 87fe7d941..9f4e9ee9d 100644
--- a/lib/routes/washingtonpost/app.tsx
+++ b/lib/routes/washingtonpost/app.tsx
@@ -146,9 +146,7 @@ const renderDescription = (content): string =>
);
}
- }
-
- if (entry.type === 'deck') {
+ } else if (entry.type === 'deck') {
return (
{entry.mime === 'text/html' ? raw(entry.content) : entry.content}
@@ -180,9 +178,7 @@ const renderDescription = (content): string =>
);
}
- }
-
- if (entry.type === 'list') {
+ } else if (entry.type === 'list') {
const ListTag = entry.subtype === 'ordered' ? 'ol' : 'ul';
return (
diff --git a/lib/routes/wechat/ershcimi.ts b/lib/routes/wechat/ershcimi.ts
index c322c5ac5..939ac7cbe 100644
--- a/lib/routes/wechat/ershcimi.ts
+++ b/lib/routes/wechat/ershcimi.ts
@@ -40,7 +40,7 @@ async function handler(ctx) {
title: $item('.weui_media_title a').text(),
description: $item('.weui_media_desc').text(),
link,
- pubDate: timezone(parseDate($item('.weui_media_extra_info').attr('title')), +8),
+ pubDate: timezone(parseDate($item('.weui_media_extra_info').attr('title')), 8),
};
});
diff --git a/lib/routes/wechat/feeddd.ts b/lib/routes/wechat/feeddd.ts
index 0f2692767..7885e2670 100644
--- a/lib/routes/wechat/feeddd.ts
+++ b/lib/routes/wechat/feeddd.ts
@@ -40,4 +40,5 @@ const handler = async (ctx) => {
ctx.set('json', ret);
return ret;
};
+// TODO: missing route export
export default handler;
diff --git a/lib/routes/weibo/keyword.ts b/lib/routes/weibo/keyword.ts
index 2ba00c5e9..2309f3dfd 100644
--- a/lib/routes/weibo/keyword.ts
+++ b/lib/routes/weibo/keyword.ts
@@ -68,9 +68,9 @@ async function handler(ctx) {
item: data
.filter((i) => i.mblog)
.map((item) => {
- item.mblog.created_at = timezone(item.mblog.created_at, +8);
+ item.mblog.created_at = timezone(item.mblog.created_at, 8);
if (item.mblog.retweeted_status && item.mblog.retweeted_status.created_at) {
- item.mblog.retweeted_status.created_at = timezone(item.mblog.retweeted_status.created_at, +8);
+ item.mblog.retweeted_status.created_at = timezone(item.mblog.retweeted_status.created_at, 8);
}
return weiboUtils.formatExtended(ctx, item.mblog, undefined, {
showAuthorInTitle: fallback(undefined, queryToBoolean(routeParams.showAuthorInTitle), true),
diff --git a/lib/routes/weibo/search/hot.tsx b/lib/routes/weibo/search/hot.tsx
index 25abbc816..c6faf8c0b 100644
--- a/lib/routes/weibo/search/hot.tsx
+++ b/lib/routes/weibo/search/hot.tsx
@@ -205,8 +205,7 @@ function seekContent(clist) {
: [],
});
stub.append(section);
- }
- if (curitem.card_type === 11) {
+ } else if (curitem.card_type === 11) {
stub.append(seekContent(curitem.card_group));
}
}
diff --git a/lib/routes/weibo/super-index.ts b/lib/routes/weibo/super-index.ts
index 1e6cc5f41..e788bbad5 100644
--- a/lib/routes/weibo/super-index.ts
+++ b/lib/routes/weibo/super-index.ts
@@ -91,7 +91,8 @@ async function handler(ctx) {
const formatExtended = weiboUtils.formatExtended(ctx, card.mblog, undefined);
resultItems.push(formatExtended);
}
- for (const card of containerData?.cards ?? []) {
+ const cards = containerData?.cards ?? [];
+ for (const card of cards) {
handleCard(ctx, card, resultItems);
if (!('card_group' in card)) {
continue;
diff --git a/lib/routes/weibo/user-bookmarks.ts b/lib/routes/weibo/user-bookmarks.ts
index 9847983e9..92ed4173b 100644
--- a/lib/routes/weibo/user-bookmarks.ts
+++ b/lib/routes/weibo/user-bookmarks.ts
@@ -143,7 +143,7 @@ async function handler(ctx) {
item.mblog.retweeted_status.created_at = data.retweeted_status.created_at;
}
} else {
- item.mblog.created_at = timezone(item.mblog.created_at, +8);
+ item.mblog.created_at = timezone(item.mblog.created_at, 8);
}
// 转发的长微博处理
diff --git a/lib/routes/weibo/user.ts b/lib/routes/weibo/user.ts
index 7241a03cb..b4a9888cc 100644
--- a/lib/routes/weibo/user.ts
+++ b/lib/routes/weibo/user.ts
@@ -126,10 +126,7 @@ async function handler(ctx) {
if (item.mblog === undefined) {
return false;
}
- if (showRetweeted === '0' && item.mblog.retweeted_status) {
- return false;
- }
- return true;
+ return !(showRetweeted === '0' && item.mblog.retweeted_status);
})
.map(async (item) => {
// TODO: unify cache key and let weiboUtils.getShowData() handle the cache? It seems safe to do so.
@@ -154,7 +151,7 @@ async function handler(ctx) {
retweeted_status.created_at = data.retweeted_status.created_at;
}
} else {
- item.mblog.created_at = timezone(created_at, +8);
+ item.mblog.created_at = timezone(created_at, 8);
}
// 转发的长微博处理
diff --git a/lib/routes/weibo/utils.ts b/lib/routes/weibo/utils.ts
index c69a48874..760f58dca 100644
--- a/lib/routes/weibo/utils.ts
+++ b/lib/routes/weibo/utils.ts
@@ -365,7 +365,7 @@ const weiboUtils = {
title += ' [视频]';
}
- uid = uid || status.user?.id;
+ uid ||= status.user?.id;
const bid = status.bid || status.id;
const guid = uid ? `https://weibo.com/${uid}/${bid}` : `https://m.weibo.cn/status/${bid}`;
const link = preferMobileLink ? `https://m.weibo.cn/status/${bid}` : guid;
diff --git a/lib/routes/wfu/news.ts b/lib/routes/wfu/news.ts
index 1dc767748..7fe7e6131 100644
--- a/lib/routes/wfu/news.ts
+++ b/lib/routes/wfu/news.ts
@@ -99,7 +99,7 @@ async function handler(ctx) {
const $ = load(item); // 将列表项加载成 html
const $item_url = 'https://www.wfu.edu.cn' + $('a').attr('href'); // 获取 每一项的url
const $title = $('a>div.txt>h1').text(); // 获取每个的标题
- const $pubdate = timezone(parseDate($('a>div.txt>span.date').text().split(':', 2)[1]), +8); // 获取发布时间
+ const $pubdate = timezone(parseDate($('a>div.txt>span.date').text().split(':', 2)[1]), 8); // 获取发布时间
// 列表上提取到的信息
// 标题 链接
diff --git a/lib/routes/whu/cs.ts b/lib/routes/whu/cs.ts
index 61e4f2efd..ece68e074 100644
--- a/lib/routes/whu/cs.ts
+++ b/lib/routes/whu/cs.ts
@@ -102,7 +102,7 @@ async function handler(ctx) {
});
item.description = content.html();
- item.pubDate = $('meta[name="PubDate"]').length ? timezone(parseDate($('meta[name="PubDate"]').attr('content')), +8) : item.pubDate;
+ item.pubDate = $('meta[name="PubDate"]').length ? timezone(parseDate($('meta[name="PubDate"]').attr('content')), 8) : item.pubDate;
return item;
})
diff --git a/lib/routes/whu/rsgis.ts b/lib/routes/whu/rsgis.ts
index 1b7948215..283a76611 100644
--- a/lib/routes/whu/rsgis.ts
+++ b/lib/routes/whu/rsgis.ts
@@ -116,7 +116,7 @@ function parseListLinkDateItem(element: Cheerio, currentUrl: string) {
return {
title,
link,
- pubDate: timezone(parseDate(pubDate, 'YYYY-MM-DD'), +8),
+ pubDate: timezone(parseDate(pubDate, 'YYYY-MM-DD'), 8),
description: title,
external,
};
diff --git a/lib/routes/whu/util.ts b/lib/routes/whu/util.ts
index e508dfa59..568030a21 100644
--- a/lib/routes/whu/util.ts
+++ b/lib/routes/whu/util.ts
@@ -107,7 +107,7 @@ const getItemDetail = async (item, rootUrl) => {
item.author = getMeta(meta, 'ContentSource');
item.category = getMeta(meta, 'Keywords')?.split(' ').filter(Boolean) ?? [];
item.guid = getMeta(meta, 'Url') ?? item.link;
- item.pubDate = getMeta(meta, 'PubDate') ? timezone(parseDate(getMeta(meta, 'PubDate')), +8) : item.pubDate;
+ item.pubDate = getMeta(meta, 'PubDate') ? timezone(parseDate(getMeta(meta, 'PubDate')), 8) : item.pubDate;
// Set enclosure information if attachments exist.
if (attachments.length > 0) {
diff --git a/lib/routes/wikipedia/current-events.ts b/lib/routes/wikipedia/current-events.ts
index b31f3cac3..616a0787e 100644
--- a/lib/routes/wikipedia/current-events.ts
+++ b/lib/routes/wikipedia/current-events.ts
@@ -268,22 +268,24 @@ async function fetchMultipleWikiContent(pageNames: string[]): Promise ({
title: item.title,
link: new URL(item.url, baseUrl).href,
- pubDate: timezone(parseDate(item.publish_date), +8),
+ pubDate: timezone(parseDate(item.publish_date), 8),
}));
const items = await Promise.all(
@@ -57,7 +57,7 @@ async function handler() {
const $ = load(response);
const content = $('.article_detail');
- item.pubDate = timezone(parseDate(content.find('b#time').text()), +8);
+ item.pubDate = timezone(parseDate(content.find('b#time').text()), 8);
content.find('h2, .tips').remove();
item.description = content.html()?.trim();
diff --git a/lib/routes/wmc-bj/publish.tsx b/lib/routes/wmc-bj/publish.tsx
index 822fa2653..b6df8e65d 100644
--- a/lib/routes/wmc-bj/publish.tsx
+++ b/lib/routes/wmc-bj/publish.tsx
@@ -46,7 +46,7 @@ async function handler(ctx) {
),
category: categories,
guid: `${currentUrl}#${datetime}`,
- pubDate: timezone(parseDate(/^[A-Z]{3}/i.test(datetime) ? datetime.replace(/^\w+/, '') : datetime, ['DD MMM HH:mm', 'MM/DD HH:mm']), +0),
+ pubDate: timezone(parseDate(/^[A-Z]{3}/i.test(datetime) ? datetime.replace(/^\w+/, '') : datetime, ['DD MMM HH:mm', 'MM/DD HH:mm']), 0),
},
];
diff --git a/lib/routes/wsj/news.ts b/lib/routes/wsj/news.ts
index 3293d29b9..ba636f1da 100644
--- a/lib/routes/wsj/news.ts
+++ b/lib/routes/wsj/news.ts
@@ -50,7 +50,7 @@ async function handler(ctx) {
let url = host;
if (category.length > 0) {
url = `${host}/news/${category}`;
- subtitle = `${subtitle} - ${category}`;
+ subtitle += ` - ${category}`;
}
const response = await got({
method: 'get',
diff --git a/lib/routes/x6d/index.ts b/lib/routes/x6d/index.ts
index 542739e89..7c300726f 100644
--- a/lib/routes/x6d/index.ts
+++ b/lib/routes/x6d/index.ts
@@ -109,7 +109,7 @@ export async function handler(ctx) {
item.title = title;
item.description = description;
- item.pubDate = timezone(parseDate($$('time').text()), +8);
+ item.pubDate = timezone(parseDate($$('time').text()), 8);
item.category = $$('b.bq-wg')
.toArray()
.map((c) => $$(c).text());
diff --git a/lib/routes/xaut/index.ts b/lib/routes/xaut/index.ts
index c9dc5b92b..92a87662f 100644
--- a/lib/routes/xaut/index.ts
+++ b/lib/routes/xaut/index.ts
@@ -50,7 +50,7 @@ async function handler(ctx) {
item = $(item);
// link原来长这样:'../info/1196/13990.htm'
const link = item.find('a').attr('href').replace(/^\.\./, 'http://www.xaut.edu.cn');
- const pubDate = timezone(parseDate(item.find('div.time').text().trim()), +8);
+ const pubDate = timezone(parseDate(item.find('div.time').text().trim()), 8);
const title = item.find('h5').text();
return {
diff --git a/lib/routes/xiaoheihe/discount.ts b/lib/routes/xiaoheihe/discount.ts
index d3137fcda..de30bf684 100644
--- a/lib/routes/xiaoheihe/discount.ts
+++ b/lib/routes/xiaoheihe/discount.ts
@@ -65,7 +65,7 @@ function getLowestDesc(priceInfo, isSuperLowest = false) {
function getHeyboxPriceDesc(heyboxPriceInfo) {
if (heyboxPriceInfo.coupon_info) {
let discountPrice = heyboxPriceInfo.cost_coin / 1000;
- discountPrice = discountPrice - heyboxPriceInfo.coupon_info.max_reduce;
+ discountPrice -= heyboxPriceInfo.coupon_info.max_reduce;
const formatPrice = Number.isSafeInteger(discountPrice) ? discountPrice.toFixed(0) : discountPrice.toFixed(2);
return `| 券后价: ${formatPrice} [${heyboxPriceInfo.coupon_info.coupon_desc}]`;
}
@@ -88,22 +88,24 @@ async function handler(ctx) {
`;
if (item.platform_infos) {
for (const platform of item.platform_infos) {
- if (platform.price) {
- if (platform.key) {
- description += `平台: ${platform.key.toUpperCase()}
`;
- }
- if (platform.price.current) {
- description += `当前价格: ${platform.price.current} ${getLowestDesc(platform.price)}
`;
- }
- if (platform.price.initial) {
- description += `原价: ${platform.price.initial}
`;
- }
- if (platform.price.discount && platform.price.discount > 0) {
- description += `折扣力度: ${getDiscountDesc(platform.price.discount)}
`;
- }
- if (platform.price.deadline_date) {
- description += `截止时间: ${platform.price.deadline_date}
`;
- }
+ if (!platform.price) {
+ continue;
+ }
+
+ if (platform.key) {
+ description += `平台: ${platform.key.toUpperCase()}
`;
+ }
+ if (platform.price.current) {
+ description += `当前价格: ${platform.price.current} ${getLowestDesc(platform.price)}
`;
+ }
+ if (platform.price.initial) {
+ description += `原价: ${platform.price.initial}
`;
+ }
+ if (platform.price.discount && platform.price.discount > 0) {
+ description += `折扣力度: ${getDiscountDesc(platform.price.discount)}
`;
+ }
+ if (platform.price.deadline_date) {
+ description += `截止时间: ${platform.price.deadline_date}
`;
}
}
} else if (item.price) {
diff --git a/lib/routes/xiaohongshu/user.ts b/lib/routes/xiaohongshu/user.ts
index b70a25a8e..4550898e4 100644
--- a/lib/routes/xiaohongshu/user.ts
+++ b/lib/routes/xiaohongshu/user.ts
@@ -81,9 +81,8 @@ async function handler(ctx) {
// Fallback to normal logic if cookie method fails
return await getUserFeeds(url, category);
}
- } else {
- return await getUserFeeds(url, category);
}
+ return await getUserFeeds(url, category);
}
async function getUserFeeds(url: string, category: string) {
diff --git a/lib/routes/xiaohongshu/util.ts b/lib/routes/xiaohongshu/util.ts
index 63ad2fb95..a3084ff28 100644
--- a/lib/routes/xiaohongshu/util.ts
+++ b/lib/routes/xiaohongshu/util.ts
@@ -26,7 +26,7 @@ const getHeaders = (cookie?: string) => ({
'Sec-Fetch-User': '?1',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36',
- ...(cookie ? { Cookie: cookie } : {}),
+ ...(cookie && { Cookie: cookie }),
});
// Fetch HTML through proxy when configured
@@ -291,9 +291,9 @@ async function getUserWithCookie(url: string) {
for (const item of state.user.notes.flat()) {
const path = paths[index];
if (path && path.includes('?')) {
- item.id = item.id + path?.slice(path.indexOf('?'));
+ item.id += path?.slice(path.indexOf('?'));
}
- index = index + 1;
+ index += 1;
}
return state.user;
}
diff --git a/lib/routes/xjtu/2yuan/news.ts b/lib/routes/xjtu/2yuan/news.ts
index 9565c0b00..140b7c38a 100644
--- a/lib/routes/xjtu/2yuan/news.ts
+++ b/lib/routes/xjtu/2yuan/news.ts
@@ -56,7 +56,7 @@ async function handler(ctx) {
return {
title: item.find('a').attr('title'),
link: `${rootUrl}${item.find('a').attr('href')}`,
- pubDate: timezone(parseDate(item.find('.dy_date').text()), +8),
+ pubDate: timezone(parseDate(item.find('.dy_date').text()), 8),
};
});
@@ -78,7 +78,7 @@ async function handler(ctx) {
.text()
.replace(/发布时间:/, '')
),
- +8
+ 8
);
return item;
diff --git a/lib/routes/xjtu/dean.ts b/lib/routes/xjtu/dean.ts
index d3d43b867..1d8940406 100644
--- a/lib/routes/xjtu/dean.ts
+++ b/lib/routes/xjtu/dean.ts
@@ -59,7 +59,7 @@ async function handler(ctx) {
return {
title,
link,
- pubDate: timezone(parseDate(item.find('span').text(), 'YYYY-MM-DD'), +8),
+ pubDate: timezone(parseDate(item.find('span').text(), 'YYYY-MM-DD'), 8),
};
});
diff --git a/lib/routes/xjtu/ee-jzxx.ts b/lib/routes/xjtu/ee-jzxx.ts
index d1103320b..fb180ba3b 100644
--- a/lib/routes/xjtu/ee-jzxx.ts
+++ b/lib/routes/xjtu/ee-jzxx.ts
@@ -71,7 +71,7 @@ async function handler(ctx) {
const infoDiv = content('div.art-tit.cont-tit');
const dateText = infoDiv.find('p span:nth-child(1)').text().replace('发布时间:', '');
- const pubDate = timezone(parseDate(dateText), +8);
+ const pubDate = timezone(parseDate(dateText), 8);
const description = content('div.art-body.wow.fadeInUp')
.clone() // 创建副本防止修改原始内容
diff --git a/lib/routes/xjtu/ee.ts b/lib/routes/xjtu/ee.ts
index 92479f904..612d7d429 100644
--- a/lib/routes/xjtu/ee.ts
+++ b/lib/routes/xjtu/ee.ts
@@ -49,7 +49,7 @@ async function handler(ctx) {
return {
title: a.text(),
link: new URL(a.attr('href'), baseUrl).href,
- pubDate: timezone(date, +8),
+ pubDate: timezone(date, 8),
};
});
diff --git a/lib/routes/xjtu/job.tsx b/lib/routes/xjtu/job.tsx
index 9d953bbe3..680179b6a 100644
--- a/lib/routes/xjtu/job.tsx
+++ b/lib/routes/xjtu/job.tsx
@@ -56,7 +56,7 @@ async function handler(ctx) {
const list = data.data.map((item) => ({
title: item.menutitle,
description: item.NR,
- pubDate: timezone(parseDate(item.SBSJ), +8),
+ pubDate: timezone(parseDate(item.SBSJ), 8),
guid: item.menuid,
link: `${baseUrl}/xsfw/sys/emaphome/website/template/detail.html?menuid=${item.menuid}&msg=TZGG&msgChild=NRXQ`,
}));
diff --git a/lib/routes/xjtu/std.tsx b/lib/routes/xjtu/std.tsx
index 70da367fb..95bb17a1b 100644
--- a/lib/routes/xjtu/std.tsx
+++ b/lib/routes/xjtu/std.tsx
@@ -64,7 +64,7 @@ async function handler(ctx) {
const content = load(detailResponse.data);
item.description = renderToString();
- item.pubDate = timezone(parseDate(content('#vsb_newscontent').parent().prev().prev().text().split(' ', 1)[0], 'YYYY年MM月DD日 HH:mm'), +8);
+ item.pubDate = timezone(parseDate(content('#vsb_newscontent').parent().prev().prev().text().split(' ', 1)[0], 'YYYY年MM月DD日 HH:mm'), 8);
return item;
})
diff --git a/lib/routes/xjtu/yz.ts b/lib/routes/xjtu/yz.ts
index 8fde0a275..859c99d84 100644
--- a/lib/routes/xjtu/yz.ts
+++ b/lib/routes/xjtu/yz.ts
@@ -49,7 +49,7 @@ async function handler(ctx) {
return {
title: a.attr('title'),
link: new URL(a.attr('href')!, baseUrl).href,
- pubDate: timezone(parseDate(item.find('span.date.fr').text()), +8),
+ pubDate: timezone(parseDate(item.find('span.date.fr').text()), 8),
} as DataItem;
});
const items = await Promise.all(
diff --git a/lib/routes/xjtu/zs.ts b/lib/routes/xjtu/zs.ts
index cb08bd67a..4cab8994c 100644
--- a/lib/routes/xjtu/zs.ts
+++ b/lib/routes/xjtu/zs.ts
@@ -70,13 +70,13 @@ export const handler = async (ctx: Context): Promise => {
const processedItem: DataItem = {
title,
description,
- pubDate: pubDateStr ? timezone(parseDate(pubDateStr), +8) : item.pubDate,
+ pubDate: pubDateStr ? timezone(parseDate(pubDateStr), 8) : item.pubDate,
category: categories,
content: {
html: description,
text: description,
},
- updated: upDatedStr ? timezone(parseDate(upDatedStr), +8) : item.updated,
+ updated: upDatedStr ? timezone(parseDate(upDatedStr), 8) : item.updated,
language,
};
diff --git a/lib/routes/xkb/index.tsx b/lib/routes/xkb/index.tsx
index 0d41be767..e1544039b 100644
--- a/lib/routes/xkb/index.tsx
+++ b/lib/routes/xkb/index.tsx
@@ -59,7 +59,7 @@ async function handler(ctx) {
) : null}
>
),
- pubDate: timezone(parseDate(item.operTime), +8),
+ pubDate: timezone(parseDate(item.operTime), 8),
link: 'https://www.xkb.com.cn/detail?id=' + item.id,
contentUrl: item.contentUrl,
author: item.metaInfo.author,
diff --git a/lib/routes/xmnn/epaper.ts b/lib/routes/xmnn/epaper.ts
index ceec1c717..eb09ecdeb 100644
--- a/lib/routes/xmnn/epaper.ts
+++ b/lib/routes/xmnn/epaper.ts
@@ -100,7 +100,7 @@ async function handler(ctx) {
content('#qw').remove();
item.description = content('.cont-b, content').html();
- item.pubDate = timezone(parseDate(content('.time').text() || content('.today').text().split()[0], ['YYYY-MM-DD HH:mm', 'YYYY年MM月DD日']), +8);
+ item.pubDate = timezone(parseDate(content('.time').text() || content('.today').text().split()[0], ['YYYY-MM-DD HH:mm', 'YYYY年MM月DD日']), 8);
return item;
})
diff --git a/lib/routes/xmnn/news.ts b/lib/routes/xmnn/news.ts
index af09b7c71..754a900a6 100644
--- a/lib/routes/xmnn/news.ts
+++ b/lib/routes/xmnn/news.ts
@@ -35,7 +35,7 @@ async function handler(ctx) {
link: item.prop('href'),
description: item.find('div.abstract').html(),
author: item.find('div.source').text(),
- pubDate: timezone(parseDate(item.find('div.time').text()), +8),
+ pubDate: timezone(parseDate(item.find('div.time').text()), 8),
};
});
@@ -51,7 +51,7 @@ async function handler(ctx) {
item.author = content('span.cont-a-src a')
.toArray()
.map((a) => content(a).text());
- item.pubDate = timezone(parseDate(content('span.time, div.pubtime div.w').contents().first().text().trim()), +8);
+ item.pubDate = timezone(parseDate(content('span.time, div.pubtime div.w').contents().first().text().trim()), 8);
return item;
})
diff --git a/lib/routes/xueqiu/fund.ts b/lib/routes/xueqiu/fund.ts
index 78bf9e247..791ca34a6 100644
--- a/lib/routes/xueqiu/fund.ts
+++ b/lib/routes/xueqiu/fund.ts
@@ -56,7 +56,7 @@ async function handler(ctx) {
const single = {
title,
description,
- pubDate: timezone(parseDate(end_date), +8),
+ pubDate: timezone(parseDate(end_date), 8),
link: appUrl,
};
diff --git a/lib/routes/xyu/notices.ts b/lib/routes/xyu/notices.ts
index bc700b68c..5943391d7 100644
--- a/lib/routes/xyu/notices.ts
+++ b/lib/routes/xyu/notices.ts
@@ -63,7 +63,7 @@ async function handler() {
title,
link: new URL(link, baseUrl).href,
description: description || title,
- pubDate: timezone(parseDate(dateText, 'YYYY-MM-DD'), +8),
+ pubDate: timezone(parseDate(dateText, 'YYYY-MM-DD'), 8),
};
})
.filter(Boolean);
diff --git a/lib/routes/yangtzeu/dongke.ts b/lib/routes/yangtzeu/dongke.ts
index d5c0b411c..e94c72ebd 100644
--- a/lib/routes/yangtzeu/dongke.ts
+++ b/lib/routes/yangtzeu/dongke.ts
@@ -52,7 +52,7 @@ async function handler(ctx) {
.text()
.match(/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/)[1]
),
- +8
+ 8
);
return item;
diff --git a/lib/routes/ycwb/index.tsx b/lib/routes/ycwb/index.tsx
index 96b1f32a8..ab7cbe89f 100644
--- a/lib/routes/ycwb/index.tsx
+++ b/lib/routes/ycwb/index.tsx
@@ -62,7 +62,7 @@ async function handler(ctx) {
) : null}
>
),
- pubDate: timezone(parseDate(item.PUBTIME), +8),
+ pubDate: timezone(parseDate(item.PUBTIME), 8),
link: item.PUBURL,
nodeName: item.NODENAME,
}));
diff --git a/lib/routes/yicai/brief.ts b/lib/routes/yicai/brief.ts
index 0c6304dd6..780318dca 100644
--- a/lib/routes/yicai/brief.ts
+++ b/lib/routes/yicai/brief.ts
@@ -42,7 +42,7 @@ async function handler(ctx) {
title: item.indexTitle,
link: `${rootUrl}${item.url}`,
description: item.newcontent,
- pubDate: timezone(parseDate(`${item.datekey} ${item.hm}`, 'YYYY.MM.DD HH:mm'), +8),
+ pubDate: timezone(parseDate(`${item.datekey} ${item.hm}`, 'YYYY.MM.DD HH:mm'), 8),
}));
return {
diff --git a/lib/routes/yicai/news.ts b/lib/routes/yicai/news.ts
index a2a4a35b3..66fe0163f 100644
--- a/lib/routes/yicai/news.ts
+++ b/lib/routes/yicai/news.ts
@@ -68,14 +68,16 @@ async function handler(ctx) {
});
for (const c of response.data.header.news) {
- if (c.EnglishName === id || c.ChannelID === id) {
- channel = {
- id: c.ChannelID,
- name: c.ChannelName,
- slug: c.EnglishName,
- };
- break;
+ if (!(c.EnglishName === id || c.ChannelID === id)) {
+ continue;
}
+
+ channel = {
+ id: c.ChannelID,
+ name: c.ChannelName,
+ slug: c.EnglishName,
+ };
+ break;
}
}
diff --git a/lib/routes/yicai/utils.ts b/lib/routes/yicai/utils.ts
index 354848f2f..22ba0604d 100644
--- a/lib/routes/yicai/utils.ts
+++ b/lib/routes/yicai/utils.ts
@@ -18,7 +18,7 @@ const ProcessItems = async (apiUrl, tryGet) => {
title: item.NewsTitle,
link: item.url.startsWith('http') ? item.url : `${rootUrl}${item.AppID === 0 ? '/vip' : ''}${item.url}`,
author: item.NewsAuthor || item.NewsSource || item.CreaterName,
- pubDate: timezone(parseDate(item.CreateDate), +8),
+ pubDate: timezone(parseDate(item.CreateDate), 8),
category: [item.ChannelName],
description: renderDescription({
image: {
diff --git a/lib/routes/yicai/video.ts b/lib/routes/yicai/video.ts
index c7c44770b..9b28757ed 100644
--- a/lib/routes/yicai/video.ts
+++ b/lib/routes/yicai/video.ts
@@ -78,14 +78,16 @@ async function handler(ctx) {
});
for (const c of response.data.header.video) {
- if (c.EnglishName === id || c.ChannelID === id) {
- channel = {
- id: c.ChannelID,
- name: c.ChannelName,
- slug: c.EnglishName,
- };
- break;
+ if (!(c.EnglishName === id || c.ChannelID === id)) {
+ continue;
}
+
+ channel = {
+ id: c.ChannelID,
+ name: c.ChannelName,
+ slug: c.EnglishName,
+ };
+ break;
}
}
diff --git a/lib/routes/yna/index.ts b/lib/routes/yna/index.ts
index 609953f7f..6138879a8 100644
--- a/lib/routes/yna/index.ts
+++ b/lib/routes/yna/index.ts
@@ -64,7 +64,7 @@ async function handler(ctx) {
const items = await Promise.all(
feed.items.map((item) =>
cache.tryGet(item.link, async () => {
- item.pubDate = lang === 'ko' ? parseDate(item.pubDate) : timezone(parseDate(item.pubDate), +9); // Timezone is only included in the pubDate of the Korean language RSS
+ item.pubDate = lang === 'ko' ? parseDate(item.pubDate) : timezone(parseDate(item.pubDate), 9); // Timezone is only included in the pubDate of the Korean language RSS
const response = await got(item.link);
const $ = load(response.data);
item.author =
diff --git a/lib/routes/ynet/list.ts b/lib/routes/ynet/list.ts
index ba41b4c3c..199a556e7 100644
--- a/lib/routes/ynet/list.ts
+++ b/lib/routes/ynet/list.ts
@@ -75,9 +75,9 @@ export const handler = async (ctx: Context): Promise => {
const processedItem: DataItem = {
title,
- pubDate: pubDateStr ? timezone(parseDate(pubDateStr), +8) : undefined,
+ pubDate: pubDateStr ? timezone(parseDate(pubDateStr), 8) : undefined,
link: linkUrl,
- updated: upDatedStr ? timezone(parseDate(upDatedStr), +8) : undefined,
+ updated: upDatedStr ? timezone(parseDate(upDatedStr), 8) : undefined,
language,
};
@@ -106,13 +106,13 @@ export const handler = async (ctx: Context): Promise => {
const processedItem: DataItem = {
title,
description,
- pubDate: pubDateStr ? timezone(parseDate(pubDateStr), +8) : item.pubDate,
+ pubDate: pubDateStr ? timezone(parseDate(pubDateStr), 8) : item.pubDate,
author: authors,
content: {
html: description,
text: description,
},
- updated: upDatedStr ? timezone(parseDate(upDatedStr), +8) : item.updated,
+ updated: upDatedStr ? timezone(parseDate(upDatedStr), 8) : item.updated,
language,
};
diff --git a/lib/routes/yomiuri/news.ts b/lib/routes/yomiuri/news.ts
index fb3771b22..d5290d3fb 100644
--- a/lib/routes/yomiuri/news.ts
+++ b/lib/routes/yomiuri/news.ts
@@ -67,7 +67,7 @@ async function handler(ctx) {
return {
title: a.text(),
link: a.attr('href'),
- pubDate: timezone(parseDate(item.find('time').attr('datetime')), +9),
+ pubDate: timezone(parseDate(item.find('time').attr('datetime')), 9),
locked: item.find('.icon-locked').length,
};
});
@@ -82,7 +82,7 @@ async function handler(ctx) {
return {
title: a.text(),
link: a.attr('href'),
- pubDate: timezone(parseDate(parent.find('time').attr('datetime')), +9),
+ pubDate: timezone(parseDate(parent.find('time').attr('datetime')), 9),
locked: parent.find('.c-list-member-only').length,
};
});
diff --git a/lib/routes/youtube/api/google.ts b/lib/routes/youtube/api/google.ts
index 5f578d62a..8c43d17a2 100644
--- a/lib/routes/youtube/api/google.ts
+++ b/lib/routes/youtube/api/google.ts
@@ -23,13 +23,15 @@ if (config.youtube && config.youtube.key) {
const keys = config.youtube.key.split(',');
for (const [index, key] of keys.entries()) {
- if (key) {
- youtube[index] = google.youtube({
- version: 'v3',
- auth: key,
- });
- count = index + 1;
+ if (!key) {
+ continue;
}
+
+ youtube[index] = google.youtube({
+ version: 'v3',
+ auth: key,
+ });
+ count = index + 1;
}
}
diff --git a/lib/routes/yxdown/news.ts b/lib/routes/yxdown/news.ts
index 5c1ee855c..1869e2495 100644
--- a/lib/routes/yxdown/news.ts
+++ b/lib/routes/yxdown/news.ts
@@ -67,7 +67,7 @@ async function handler(ctx) {
content('h1, .intro').remove();
item.description = content('.news').html();
- item.pubDate = timezone(parseDate(content('meta[property="og:release_date"]').attr('content')), +8);
+ item.pubDate = timezone(parseDate(content('meta[property="og:release_date"]').attr('content')), 8);
return item;
})
diff --git a/lib/routes/yxdown/recommend.ts b/lib/routes/yxdown/recommend.ts
index 492eb167c..df54c25a5 100644
--- a/lib/routes/yxdown/recommend.ts
+++ b/lib/routes/yxdown/recommend.ts
@@ -67,7 +67,7 @@ async function handler() {
content('h1, .intro').remove();
item.description = content('.news').html();
- item.pubDate = timezone(parseDate(content('meta[property="og:release_date"]').attr('content')), +8);
+ item.pubDate = timezone(parseDate(content('meta[property="og:release_date"]').attr('content')), 8);
return item;
})
diff --git a/lib/routes/yxrb/home.ts b/lib/routes/yxrb/home.ts
index 5465d5e87..d9f859b81 100644
--- a/lib/routes/yxrb/home.ts
+++ b/lib/routes/yxrb/home.ts
@@ -58,7 +58,7 @@ async function handler(ctx) {
const response = await got(item.link);
const $ = load(response.data);
- item.author = item.author ?? $('.author-info .name a').text().split('作者 : ', 2)[1];
+ item.author ??= $('.author-info .name a').text().split('作者 : ', 2)[1];
item.pubDate = timezone(
parseDate(
$('.publish-time')
diff --git a/lib/routes/yyets/article.ts b/lib/routes/yyets/article.ts
index d919cab0b..ef6a6a7ed 100644
--- a/lib/routes/yyets/article.ts
+++ b/lib/routes/yyets/article.ts
@@ -60,7 +60,7 @@ async function handler(ctx) {
title: e.find('h3 a').text(),
link: `${baseURL}${e.find('h3 a').attr('href')}`,
author: e.find('p a').text(),
- pubDate: timezone(parseDate(e.find('p').eq(2).text()), +8),
+ pubDate: timezone(parseDate(e.find('p').eq(2).text()), 8),
};
});
diff --git a/lib/routes/zaker/utils.ts b/lib/routes/zaker/utils.ts
index b625c592b..262322d6b 100644
--- a/lib/routes/zaker/utils.ts
+++ b/lib/routes/zaker/utils.ts
@@ -158,7 +158,7 @@ export const parseList = ($: cheerio.CheerioAPI) => {
description: item.desc,
link: 'https:' + item.url,
author: item.author_name,
- pubDate: timezone(parseDate(item.date, 'MM月DD日'), +8),
+ pubDate: timezone(parseDate(item.date, 'MM月DD日'), 8),
category: item.tag.map((t) => t.tag),
image: item.thumbnail_mpic,
})) as DataItem[];
diff --git a/lib/routes/zaobao/util.tsx b/lib/routes/zaobao/util.tsx
index e96fb1ea9..b7656da86 100644
--- a/lib/routes/zaobao/util.tsx
+++ b/lib/routes/zaobao/util.tsx
@@ -52,7 +52,7 @@ export const parseList = async (
return {
title: isSingapore ? $item.text().trim() : ($item.attr('title')?.trim() as string),
link: $item.attr('href') as string,
- pubDate: timezone($item.next().text().trim().includes(':') ? parseDate($item.next().text().trim(), 'HH:mm') : parseDate($item.next().text().trim(), 'MM月DD日'), +8),
+ pubDate: timezone($item.next().text().trim().includes(':') ? parseDate($item.next().text().trim(), 'HH:mm') : parseDate($item.next().text().trim(), 'MM月DD日'), 8),
};
}
const response = await ofetch.raw(new URL($item.attr('href') as string, origin).href);
@@ -122,7 +122,7 @@ export const parseList = async (
};
export const orderContent = (parent) => {
- for (const [i, e] of parent
+ const sortedChildren = parent
.children()
.toArray()
.toSorted((a, b) => {
@@ -144,8 +144,8 @@ export const orderContent = (parent) => {
)
).toString();
return a - b;
- })
- .entries()) {
+ });
+ for (const [i, e] of sortedChildren.entries()) {
parent.find((element) => e(element)).attr('s', i);
parent.append(e);
}
diff --git a/lib/routes/zhibo8/forum.ts b/lib/routes/zhibo8/forum.ts
index ece977fad..df0a87df7 100644
--- a/lib/routes/zhibo8/forum.ts
+++ b/lib/routes/zhibo8/forum.ts
@@ -53,7 +53,7 @@ async function handler(ctx) {
description,
author,
link,
- pubDate: timezone(parseDate(date, 'YYYY-MM-DD HH:mm'), +8),
+ pubDate: timezone(parseDate(date, 'YYYY-MM-DD HH:mm'), 8),
};
});
})
diff --git a/lib/routes/zhibo8/luxiang.ts b/lib/routes/zhibo8/luxiang.ts
index 3531f8826..487332f37 100644
--- a/lib/routes/zhibo8/luxiang.ts
+++ b/lib/routes/zhibo8/luxiang.ts
@@ -39,7 +39,7 @@ async function handler(ctx) {
return {
title: `${item.previousSibling.data.replace(' | ', '')} ${$(item).text()}`,
link: `${rootUrl}${href}`,
- pubDate: timezone(parseDate(`${href.replace(`/${category}/`, '').slice(0, 4)} ${dateStr}`, 'YYYY M月D日'), +8),
+ pubDate: timezone(parseDate(`${href.replace(`/${category}/`, '').slice(0, 4)} ${dateStr}`, 'YYYY M月D日'), 8),
};
});
});
diff --git a/lib/routes/zhibo8/more.ts b/lib/routes/zhibo8/more.ts
index c149b1ed6..7b2cbc80f 100644
--- a/lib/routes/zhibo8/more.ts
+++ b/lib/routes/zhibo8/more.ts
@@ -66,7 +66,7 @@ async function handler(ctx) {
return {
title: a.text(),
link: `https:${a.attr('href')}`,
- pubDate: timezone(parseDate(item.find('span.postTime').text()), +8),
+ pubDate: timezone(parseDate(item.find('span.postTime').text()), 8),
category: item.attr('data-label').split(',').filter(Boolean),
};
});
@@ -79,7 +79,7 @@ async function handler(ctx) {
list = response.data.data.list.map((item) => ({
title: item.title,
link: `https:${item.url}`,
- pubDate: timezone(parseDate(item.createtime), +8),
+ pubDate: timezone(parseDate(item.createtime), 8),
}));
}
diff --git a/lib/routes/zhibo8/post.ts b/lib/routes/zhibo8/post.ts
index ebd310233..98d72ffb5 100644
--- a/lib/routes/zhibo8/post.ts
+++ b/lib/routes/zhibo8/post.ts
@@ -46,7 +46,7 @@ async function handler(ctx) {
.match(/\d{4}-\d{2}-\d{2} \d{2}:\d{2}/)[0],
'YYYY-MM-DD HH:mm'
),
- +8
+ 8
);
const single = {
diff --git a/lib/routes/zhihu/execlib/x-zse-96-v3.ts b/lib/routes/zhihu/execlib/x-zse-96-v3.ts
index 9fe7ffa82..5420d9d7a 100644
--- a/lib/routes/zhihu/execlib/x-zse-96-v3.ts
+++ b/lib/routes/zhihu/execlib/x-zse-96-v3.ts
@@ -1,4 +1,4 @@
-// oxlint-disable unicorn/prefer-code-point unicorn/prefer-single-call unicorn-js/prefer-array-from-map unicorn/prefer-spread
+// oxlint-disable unicorn/prefer-code-point unicorn/prefer-single-call unicorn-js/prefer-array-from-map unicorn/prefer-spread unicorn-js/no-array-concat-in-loop
// Credit:
// https://blog.csdn.net/zjq592767809/article/details/126512798
// https://blog.csdn.net/zhoumi_/article/details/126659351
@@ -97,7 +97,7 @@ const preProcess = (md5Str) => {
return __g_r.concat(__g_x);
};
-const encrypt = (md5Str) => {
+export const encrypt = (md5Str) => {
const processed = preProcess(md5Str);
let current = 0;
@@ -122,5 +122,3 @@ const encrypt = (md5Str) => {
}
return resultStr;
};
-
-export default encrypt;
diff --git a/lib/routes/zhihu/pin/utils.ts b/lib/routes/zhihu/pin/utils.ts
index 0709c423b..c7dc3f7ed 100644
--- a/lib/routes/zhihu/pin/utils.ts
+++ b/lib/routes/zhihu/pin/utils.ts
@@ -54,7 +54,7 @@ const generateData = (data) =>
const t = target.origin_pin;
const origin_link = `转发原文:`;
const origin_description = generateDescription(t, `${t.author.name}:`);
- description = `${description} ${origin_link} ${origin_description}`;
+ description += ` ${origin_link} ${origin_description}`;
}
return {
title,
diff --git a/lib/routes/zhihu/utils.ts b/lib/routes/zhihu/utils.ts
index 91c8de65f..296b28bdf 100644
--- a/lib/routes/zhihu/utils.ts
+++ b/lib/routes/zhihu/utils.ts
@@ -5,7 +5,7 @@ import cache from '@/utils/cache';
import md5 from '@/utils/md5';
import ofetch from '@/utils/ofetch';
-import g_encrypt from './execlib/x-zse-96-v3';
+import { encrypt as g_encrypt } from './execlib/x-zse-96-v3';
export const header = {
'x-api-version': '3.0.91',
@@ -84,7 +84,7 @@ export const getSignedHeader = async (url: string, apiPath: string) => {
return script.match(/__g\.ck\|\|"([\w+/=\\]*)",_=/)?.[1] || '';
});
if (zseCk) {
- cookieStr = `${cookieStr}; __zse_ck=${zseCk}`;
+ cookieStr += `; __zse_ck=${zseCk}`;
}
}
diff --git a/lib/routes/zju/cse/index.ts b/lib/routes/zju/cse/index.ts
index bb71c2100..77cf51742 100644
--- a/lib/routes/zju/cse/index.ts
+++ b/lib/routes/zju/cse/index.ts
@@ -79,7 +79,7 @@ async function handler(ctx) {
const infoDiv = content('span.xi14').text();
const dateText = infoDiv.match(/\b\d{4}-\d{2}-\d{2}\b/);
- const pubDate = timezone(parseDate(dateText ? dateText[0] : ''), +8);
+ const pubDate = timezone(parseDate(dateText ? dateText[0] : ''), 8);
// 获取正文
const description = content('div.wp_articlecontent').html();
diff --git a/lib/routes/zju/grs/index.ts b/lib/routes/zju/grs/index.ts
index a9a94b14e..2d1898eea 100644
--- a/lib/routes/zju/grs/index.ts
+++ b/lib/routes/zju/grs/index.ts
@@ -49,7 +49,7 @@ async function handler(ctx) {
item = $(item);
return {
title: item.find('h3').attr('title'),
- pubDate: timezone(parseDate(item.find('.date').text().trim(), 'YY-MM-DD'), +8),
+ pubDate: timezone(parseDate(item.find('.date').text().trim(), 'YY-MM-DD'), 8),
link: `http://www.grs.zju.edu.cn${item.find('a').eq(-1).attr('href')}`,
description: item.find('p').text(),
};
diff --git a/lib/routes/zjut/cs/index.ts b/lib/routes/zjut/cs/index.ts
index 165f1f5e5..ae027a433 100644
--- a/lib/routes/zjut/cs/index.ts
+++ b/lib/routes/zjut/cs/index.ts
@@ -56,7 +56,7 @@ async function handler(ctx) {
} else if (!link.startsWith('http')) {
link = 'https://' + host + '/jsp/' + link;
}
- const pubDate = timezone(parseDate(cheerioItem.find('.datetime').text().slice(1, -1)), +8);
+ const pubDate = timezone(parseDate(cheerioItem.find('.datetime').text().slice(1, -1)), 8);
return {
title,
diff --git a/lib/routes/zjut/jwc/index.ts b/lib/routes/zjut/jwc/index.ts
index 04e202dcb..9e6c86b75 100644
--- a/lib/routes/zjut/jwc/index.ts
+++ b/lib/routes/zjut/jwc/index.ts
@@ -68,7 +68,7 @@ async function handler(ctx) {
} else if (!link.startsWith('http')) {
link = rootUrl.slice(0, -1) + link;
}
- const pubDate = timezone(parseDate(cheerioItem.find('.news_meta').text()), +8);
+ const pubDate = timezone(parseDate(cheerioItem.find('.news_meta').text()), 8);
return {
title,
diff --git a/lib/routes/zjut/www/index.ts b/lib/routes/zjut/www/index.ts
index 6d2e0544b..07c4c5cb8 100644
--- a/lib/routes/zjut/www/index.ts
+++ b/lib/routes/zjut/www/index.ts
@@ -71,7 +71,7 @@ async function handler(ctx) {
pubDate: Date.now(),
};
}
- const pubDate = timezone(parseDate(dateText), +8);
+ const pubDate = timezone(parseDate(dateText), 8);
return {
title,
diff --git a/lib/routes/zuvio/student5.ts b/lib/routes/zuvio/student5.ts
index d99219879..971239877 100644
--- a/lib/routes/zuvio/student5.ts
+++ b/lib/routes/zuvio/student5.ts
@@ -43,7 +43,7 @@ async function handler(ctx) {
const items = data.articles.map((item) => ({
title: item.title,
description: item.abstract,
- pubDate: timezone(parseDate(item.created_at), +8),
+ pubDate: timezone(parseDate(item.created_at), 8),
link: `${rootUrl}/article/${item.id}`,
api: `${apiUrl}/article/${item.id}`,
author: `${item.university} ${item.user_name}`,
diff --git a/lib/utils/cache/memory.ts b/lib/utils/cache/memory.ts
index b875d6eef..8d3e55899 100644
--- a/lib/utils/cache/memory.ts
+++ b/lib/utils/cache/memory.ts
@@ -21,7 +21,7 @@ export default {
if (key && status.available && clients.memoryCache) {
let value = clients.memoryCache.get(key, { updateAgeOnGet: refresh }) as string | undefined;
if (value) {
- value = value + '';
+ value += '';
}
return value;
}
diff --git a/lib/utils/cache/redis.ts b/lib/utils/cache/redis.ts
index 94065780c..cd37b8771 100644
--- a/lib/utils/cache/redis.ts
+++ b/lib/utils/cache/redis.ts
@@ -47,7 +47,7 @@ export default {
// redisClient.set(cacheTtlKey, cacheTtl, 'EX', cacheTtl);
}
clients.redisClient.expire(key, cacheTtl);
- value = value + '';
+ value += '';
}
return value || '';
}
diff --git a/lib/utils/camelcase-keys.spec.ts b/lib/utils/camelcase-keys.spec.ts
index 35b3d073e..56f19033f 100644
--- a/lib/utils/camelcase-keys.spec.ts
+++ b/lib/utils/camelcase-keys.spec.ts
@@ -76,7 +76,7 @@ describe('test camelcase keys', () => {
},
null,
undefined,
- +0,
+ 0,
-0,
Infinity,
{
@@ -90,7 +90,7 @@ describe('test camelcase keys', () => {
},
null,
undefined,
- +0,
+ 0,
-0,
Infinity,
{
diff --git a/lib/utils/common-config.ts b/lib/utils/common-config.ts
index 80b5d3b88..9ee7c61b4 100644
--- a/lib/utils/common-config.ts
+++ b/lib/utils/common-config.ts
@@ -43,7 +43,7 @@ function getProp(data, prop, $) {
return replaceParams(data, result, $);
}
-async function buildData(data) {
+export default async function buildData(data) {
const response = await ofetch.raw(data.url);
const contentType = response.headers.get('content-type') || '';
// 若没有指定编码,则默认utf-8
@@ -76,5 +76,4 @@ async function buildData(data) {
};
}
-export default buildData;
export { getProp, replaceParams, transElemText };
diff --git a/lib/utils/header-generator.ts b/lib/utils/header-generator.ts
index 83f3de845..9a974ede6 100644
--- a/lib/utils/header-generator.ts
+++ b/lib/utils/header-generator.ts
@@ -23,11 +23,7 @@ const isValidHeader = (headers: Record, browser: string): boolea
}
}
- if (browser === 'safari' && userAgent.includes('Applebot')) {
- return false;
- }
-
- return true;
+ return !(browser === 'safari' && userAgent.includes('Applebot'));
};
/**
diff --git a/lib/utils/ofetch.ts b/lib/utils/ofetch.ts
index 359a73d4e..3d572308a 100644
--- a/lib/utils/ofetch.ts
+++ b/lib/utils/ofetch.ts
@@ -13,7 +13,7 @@ declare module 'ofetch' {
config.enableRemoteDebugging && process.env.NODE_ENV === 'dev' && register();
-const rofetch = createFetch({ fetch: (...args: Parameters) => fetch(...args) }).create({
+const rofetch = createFetch({ fetch: (input: Parameters[0], init?: Parameters[1]) => fetch(input, init) }).create({
retryStatusCodes: [400, 408, 409, 425, 429, 500, 502, 503, 504],
retry: config.requestRetry,
retryDelay: 1000,
diff --git a/lib/utils/playwright.ts b/lib/utils/playwright.ts
index 05028563e..d5cf4e25d 100644
--- a/lib/utils/playwright.ts
+++ b/lib/utils/playwright.ts
@@ -117,14 +117,12 @@ const scheduleClose = (browser: Browser, timeout = 30000) => {
/**
* @returns Playwright browser context (native `newPage()` shares state across calls)
*/
-const outPlaywright = async () => {
+export default async function outPlaywright() {
const currentProxy = proxy.getCurrentProxy();
const { browser, context } = await launchBrowser(currentProxy && proxy.proxyObj.url_regex === '.*' ? currentProxy : null);
scheduleClose(browser);
return context;
-};
-
-export default outPlaywright;
+}
// No-op in Node.js environment (used by Worker build via alias)
export const setBrowserBinding = (_binding: any) => {};
diff --git a/lib/utils/playwright.worker.ts b/lib/utils/playwright.worker.ts
index e3215fc81..9ee89908a 100644
--- a/lib/utils/playwright.worker.ts
+++ b/lib/utils/playwright.worker.ts
@@ -36,13 +36,11 @@ const scheduleClose = (browser: Browser) => {
/**
* @returns Playwright browser context (native `newPage()` shares state across calls)
*/
-const outPlaywright = async () => {
+export default async function outPlaywright() {
const { browser, context } = await launchBrowser();
scheduleClose(browser);
return context;
-};
-
-export default outPlaywright;
+}
/**
* @returns Playwright page
diff --git a/lib/utils/proxy/multi-proxy.ts b/lib/utils/proxy/multi-proxy.ts
index 3f386afa1..35042abe7 100644
--- a/lib/utils/proxy/multi-proxy.ts
+++ b/lib/utils/proxy/multi-proxy.ts
@@ -55,12 +55,14 @@ const createMultiProxy = (proxyUris: string[], proxyObj: Config['proxy']): Multi
const healthCheck = () => {
const now = Date.now();
for (const proxy of proxies) {
- if (!proxy.isActive && proxy.lastFailureTime && now - proxy.lastFailureTime > healthCheckInterval) {
- proxy.isActive = true;
- proxy.failureCount = 0;
- delete proxy.lastFailureTime;
- logger.info(`Proxy ${proxy.uri} marked as active again after health check`);
+ if (!(!proxy.isActive && proxy.lastFailureTime && now - proxy.lastFailureTime > healthCheckInterval)) {
+ continue;
}
+
+ proxy.isActive = true;
+ proxy.failureCount = 0;
+ delete proxy.lastFailureTime;
+ logger.info(`Proxy ${proxy.uri} marked as active again after health check`);
}
};
diff --git a/lib/utils/proxy/unify-proxy.ts b/lib/utils/proxy/unify-proxy.ts
index bbdff834e..c5a149fec 100644
--- a/lib/utils/proxy/unify-proxy.ts
+++ b/lib/utils/proxy/unify-proxy.ts
@@ -5,7 +5,7 @@ const defaultProtocol = 'http';
const possibleProtocol = ['http', 'https', 'socks', 'socks4', 'socks4a', 'socks5', 'socks5h'];
const unifyProxy = (proxyUri: Config['proxyUri'] | string, proxyObj: Config['proxy']) => {
- proxyObj = proxyObj || {};
+ proxyObj ||= {};
const [oriProxyUri, oriProxyObj] = [proxyUri, proxyObj];
proxyObj = { ...proxyObj };
diff --git a/lib/utils/readable-social.test.ts b/lib/utils/readable-social.test.ts
index 07759c463..58b9c74d4 100644
--- a/lib/utils/readable-social.test.ts
+++ b/lib/utils/readable-social.test.ts
@@ -11,7 +11,7 @@ describe('fallback', () => {
test('应该返回默认值', () => {
expect(fallback(undefined, null, 'default')).toBe('default');
- expect(fallback(null, undefined, 3.14)).toBe(3.14);
+ expect(fallback(null, undefined, Math.PI)).toBe(Math.PI);
});
});
@@ -64,7 +64,7 @@ describe('queryToFloat', () => {
});
test('should process array input', () => {
- expect(queryToFloat(['3.14'])).toBe(3.14);
+ expect(queryToFloat([String(Math.PI)])).toBe(Math.PI);
});
test('should handle empty array', () => {
@@ -76,6 +76,6 @@ describe('queryToFloat', () => {
});
test('should handle edge cases', () => {
- expect(queryToFloat('3.1415926')).toBeCloseTo(3.141_592_6);
+ expect(queryToFloat(String(Math.PI))).toBeCloseTo(Math.PI);
});
});
diff --git a/lib/utils/readable-social.ts b/lib/utils/readable-social.ts
index 7ce755b14..e7980ba93 100644
--- a/lib/utils/readable-social.ts
+++ b/lib/utils/readable-social.ts
@@ -19,10 +19,7 @@ const queryToBoolean = (s) => {
s = s[0];
}
s = s.toString();
- if (s.toLowerCase() === 'false' || s === '0') {
- return false;
- }
- return true;
+ return !(s.toLowerCase() === 'false' || s === '0');
};
const queryToInteger = (s) => {
diff --git a/lib/utils/request-rewriter/get.ts b/lib/utils/request-rewriter/get.ts
index bb268ab3a..d269beb3d 100644
--- a/lib/utils/request-rewriter/get.ts
+++ b/lib/utils/request-rewriter/get.ts
@@ -46,7 +46,7 @@ const getWrappedGet: (origin: T) => T = (origin) =>
logger.debug(`Outgoing request: ${options.method || 'GET'} ${url}`);
- options.headers = options.headers || {};
+ options.headers ||= {};
const headersLowerCaseKeys = new Set(Object.keys(options.headers).map((key) => key.toLowerCase()));
// ua
diff --git a/lib/utils/wechat-mp.ts b/lib/utils/wechat-mp.ts
index 7e5ebc86e..0e20e0337 100644
--- a/lib/utils/wechat-mp.ts
+++ b/lib/utils/wechat-mp.ts
@@ -668,7 +668,7 @@ const finishArticleItem = async (item, setMpNameAsAuthor = false, skipLink = fal
item.link = skipLink ? item.link : fetchedItem.link || item.link;
break;
default:
- item[key] = item[key] || fetchedItem[key];
+ item[key] ||= fetchedItem[key];
}
}
return item;
diff --git a/package.json b/package.json
index 8bf609ebc..85a1435ac 100644
--- a/package.json
+++ b/package.json
@@ -177,7 +177,7 @@
"eslint-plugin-n": "18.1.0",
"eslint-plugin-regexp": "3.1.0",
"eslint-plugin-simple-import-sort": "13.0.0",
- "eslint-plugin-unicorn": "66.0.0",
+ "eslint-plugin-unicorn": "68.0.0",
"eslint-plugin-yml": "3.4.0",
"fast-string-width": "3.0.2",
"fs-extra": "11.3.5",
@@ -224,7 +224,7 @@
"engines": {
"node": "^22.20.0 || ^24"
},
- "packageManager": "pnpm@10.33.4+sha512.1c67b3b359b2d408119ba1ed289f34b8fc3c6873412bec6fd264fbdc82489e510fcbecb9ce9d22dae7f3b76269d8441046014bdca53b9979cd7a561ad631b800",
+ "packageManager": "pnpm@10.34.4+sha512.8768be55200ae3f2226b6527fcca2687e14bc4e5f12d7721a0f25da3df47915177058648db4177baf348120fa0ba2752d8d8d93f6beaf1fe64ae18da8de961af",
"pnpm": {
"onlyBuiltDependencies": [
"bufferutil",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index a34187037..57fa6917a 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -387,8 +387,8 @@ importers:
specifier: 13.0.0
version: 13.0.0(eslint@10.5.0(jiti@2.6.1))
eslint-plugin-unicorn:
- specifier: 66.0.0
- version: 66.0.0(eslint@10.5.0(jiti@2.6.1))
+ specifier: 68.0.0
+ version: 68.0.0(eslint@10.5.0(jiti@2.6.1))
eslint-plugin-yml:
specifier: 3.4.0
version: 3.4.0(eslint@10.5.0(jiti@2.6.1))
@@ -531,8 +531,8 @@ packages:
resolution: {integrity: sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==}
engines: {node: '>=6.9.0'}
- '@babel/helper-validator-identifier@8.0.0':
- resolution: {integrity: sha512-kXxQVZHNOctSJJsqzmcbPSCEkM6oHNnDIkua7g9RCO9xRHj2eCiKvRx2KPdfWR9QxcGWnK/oArrtunmie3rL9g==}
+ '@babel/helper-validator-identifier@8.0.2':
+ resolution: {integrity: sha512-9Fr9QeyCAyi1BR1jKZ6uYQ24EIhQUx5ReHfQU7drOE+TPOb+w11/dsqLkMOT2U29OdCT71XajrOT8xDc1C7orA==}
engines: {node: ^22.18.0 || >=24.11.0}
'@babel/parser@7.29.7':
@@ -2815,8 +2815,8 @@ packages:
base64-js@1.5.1:
resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==}
- baseline-browser-mapping@2.10.37:
- resolution: {integrity: sha512-girxaJ7WZssDOFhzCGZTDKoTa1gk6A1TbflaYTpykLJ4UU9Fz9kx1aREM8JCuoVHbL8X8T/mJg7w2oYSq72Oig==}
+ baseline-browser-mapping@2.10.38:
+ resolution: {integrity: sha512-31/02mVB4yuQU6adKk5SlY6m+mxDwUq5KZkyYgnLrrKl7TEm1+3PyDtDBz2kOv/wxZz41GHsvV1A/u6RmiyBvw==}
engines: {node: '>=6.0.0'}
hasBin: true
@@ -3212,7 +3212,7 @@ packages:
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
difflib@https://codeload.github.com/postlight/difflib.js/tar.gz/32e8e38c7fcd935241b9baab71bb432fd9b166ed:
- resolution: {gitHosted: true, tarball: https://codeload.github.com/postlight/difflib.js/tar.gz/32e8e38c7fcd935241b9baab71bb432fd9b166ed}
+ resolution: {tarball: https://codeload.github.com/postlight/difflib.js/tar.gz/32e8e38c7fcd935241b9baab71bb432fd9b166ed}
version: 0.2.6
discord-api-types@0.38.49:
@@ -3280,8 +3280,8 @@ packages:
engines: {node: '>=14'}
hasBin: true
- electron-to-chromium@1.5.372:
- resolution: {integrity: sha512-M3yhbAlilnwqC8D21t28UCDGHyitShTmmLRU/H+b74P6Ski16Nb9HONYEaVpMj/pwC7BEo5B95FpjODLCWbtfA==}
+ electron-to-chromium@1.5.376:
+ resolution: {integrity: sha512-cUVA7/RvbFTEuw/i3obUwDTRIXojaxkResf+ibByPFxjc6XK3VNtcQXV0NSbAlJ0FMjcJGgftVVB4Qo184EXvA==}
emoji-regex@10.6.0:
resolution: {integrity: sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==}
@@ -3432,8 +3432,8 @@ packages:
peerDependencies:
eslint: '>=5.0.0'
- eslint-plugin-unicorn@66.0.0:
- resolution: {integrity: sha512-+ywdy8T3foyZ2t3nRBujGa3vfOVMobHIi5iLB0L+fogdVO3EiUJ4BAyIacogWytnweLw3hgT70LQL9KoKTY/kA==}
+ eslint-plugin-unicorn@68.0.0:
+ resolution: {integrity: sha512-mHYWvX948Q4H3bGc39bsNMxD/leOuNI+Iws9NVsoSz5VA7EGP86wnz7mZ/SPSvRhefT8L4hd8DHfDuGC+lIoCQ==}
engines: {node: '>=22'}
peerDependencies:
eslint: '>=10.4'
@@ -4531,8 +4531,8 @@ packages:
peerDependencies:
undici: ^6
- node-releases@2.0.47:
- resolution: {integrity: sha512-Uzmd6LXpouKo8EUK68IjH4+E01w/hXyV3R3g/geCJo+rXLNfh1xucB+LOzYEOQPSiUK3h/xZf0cQGcSsmyL2Og==}
+ node-releases@2.0.48:
+ resolution: {integrity: sha512-1uz8041X6LoI6ZSdZacM9lVY28vuzDlSKitnpbSNK0RfKoIJkX29NBPVEFXhnuSuEOA9Ww0xnPJ+ILWbGAv8DA==}
engines: {node: '>=18'}
nodemailer@9.0.0:
@@ -6003,7 +6003,7 @@ snapshots:
'@babel/helper-validator-identifier@7.29.7': {}
- '@babel/helper-validator-identifier@8.0.0': {}
+ '@babel/helper-validator-identifier@8.0.2': {}
'@babel/parser@7.29.7':
dependencies:
@@ -6025,7 +6025,7 @@ snapshots:
'@babel/types@8.0.0':
dependencies:
'@babel/helper-string-parser': 8.0.0
- '@babel/helper-validator-identifier': 8.0.0
+ '@babel/helper-validator-identifier': 8.0.2
'@bbob/core@4.3.1':
dependencies:
@@ -7836,7 +7836,7 @@ snapshots:
base64-js@1.5.1: {}
- baseline-browser-mapping@2.10.37: {}
+ baseline-browser-mapping@2.10.38: {}
basic-ftp@5.3.1: {}
@@ -7886,10 +7886,10 @@ snapshots:
browserslist@4.28.2:
dependencies:
- baseline-browser-mapping: 2.10.37
+ baseline-browser-mapping: 2.10.38
caniuse-lite: 1.0.30001799
- electron-to-chromium: 1.5.372
- node-releases: 2.0.47
+ electron-to-chromium: 1.5.376
+ node-releases: 2.0.48
update-browserslist-db: 1.2.3(browserslist@4.28.2)
buffer-equal-constant-time@1.0.1: {}
@@ -8256,7 +8256,7 @@ snapshots:
minimatch: 9.0.9
semver: 7.8.4
- electron-to-chromium@1.5.372: {}
+ electron-to-chromium@1.5.376: {}
emoji-regex@10.6.0: {}
@@ -8458,7 +8458,7 @@ snapshots:
dependencies:
eslint: 10.5.0(jiti@2.6.1)
- eslint-plugin-unicorn@66.0.0(eslint@10.5.0(jiti@2.6.1)):
+ eslint-plugin-unicorn@68.0.0(eslint@10.5.0(jiti@2.6.1)):
dependencies:
'@babel/helper-validator-identifier': 7.29.7
'@eslint-community/eslint-utils': 4.9.1(eslint@10.5.0(jiti@2.6.1))
@@ -9864,7 +9864,7 @@ snapshots:
transitivePeerDependencies:
- utf-8-validate
- node-releases@2.0.47: {}
+ node-releases@2.0.48: {}
nodemailer@9.0.0: {}
@@ -10395,7 +10395,7 @@ snapshots:
rolldown-plugin-dts@0.26.0(rolldown@1.1.1)(typescript@5.9.3):
dependencies:
'@babel/generator': 8.0.0
- '@babel/helper-validator-identifier': 8.0.0
+ '@babel/helper-validator-identifier': 8.0.2
'@babel/parser': 8.0.0
ast-kit: 3.0.0
birpc: 4.0.0
diff --git a/scripts/workflow/build-docs.ts b/scripts/workflow/build-docs.ts
index 69fc1d2aa..351525ae8 100644
--- a/scripts/workflow/build-docs.ts
+++ b/scripts/workflow/build-docs.ts
@@ -73,10 +73,12 @@ for (const namespace in namespaces) {
let defaultCategory = nsData.categories?.[0];
if (!defaultCategory) {
for (const routePath in nsData.routes) {
- if (nsData.routes[routePath].categories) {
- defaultCategory = nsData.routes[routePath].categories[0];
- break;
+ if (!nsData.routes[routePath].categories) {
+ continue;
}
+
+ defaultCategory = nsData.routes[routePath].categories[0];
+ break;
}
}
if (!defaultCategory) {
diff --git a/scripts/workflow/build-routes.ts b/scripts/workflow/build-routes.ts
index 6360a677c..52a9ec09a 100644
--- a/scripts/workflow/build-routes.ts
+++ b/scripts/workflow/build-routes.ts
@@ -38,10 +38,12 @@ for (const namespace in namespacesToProcess) {
let defaultCategory = namespaceData.categories?.[0];
if (!defaultCategory) {
for (const path in namespaceData.routes) {
- if (namespaceData.routes[path].categories) {
- defaultCategory = namespaceData.routes[path].categories[0];
- break;
+ if (!namespaceData.routes[path].categories) {
+ continue;
}
+
+ defaultCategory = namespaceData.routes[path].categories[0];
+ break;
}
}
if (!defaultCategory) {