hexo-adsense 1.0.26 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/LICENSE +0 -0
  3. package/dist/index.cjs +757 -0
  4. package/dist/index.d.cts +2 -0
  5. package/dist/index.d.mts +2 -0
  6. package/dist/index.d.ts +2 -0
  7. package/dist/index.js +740 -0
  8. package/dist/index.mjs +740 -0
  9. package/dist/source/adblock.css +2 -0
  10. package/{lib → dist}/source/adblock.js +0 -0
  11. package/{lib → dist}/source/article-ads.css +0 -0
  12. package/dist/source/article-ads.js +1 -0
  13. package/{lib/source/article-ads.js → dist/source/article-ads.old.js} +0 -0
  14. package/{lib → dist}/source/blogger-redirect.html +0 -0
  15. package/{lib → dist}/source/https.js +0 -0
  16. package/{lib → dist}/source/in_article_ads_test.html +0 -0
  17. package/package.json +122 -37
  18. package/{README.md → readme.md} +29 -11
  19. package/lib/index.d.ts +0 -1
  20. package/lib/index.js +0 -85
  21. package/lib/packages/hexo-cli-extras/lib/env.d.ts +0 -3
  22. package/lib/packages/hexo-cli-extras/lib/env.js +0 -49
  23. package/lib/packages/hexo-extend-injector2/index.d.ts +0 -2
  24. package/lib/packages/hexo-extend-injector2/index.js +0 -12
  25. package/lib/packages/hexo-extend-injector2/lib/bundle/css-bundle.d.ts +0 -2
  26. package/lib/packages/hexo-extend-injector2/lib/bundle/css-bundle.js +0 -64
  27. package/lib/packages/hexo-extend-injector2/lib/bundle/css-generator.d.ts +0 -2
  28. package/lib/packages/hexo-extend-injector2/lib/bundle/css-generator.js +0 -12
  29. package/lib/packages/hexo-extend-injector2/lib/bundle/handle-data-pre.d.ts +0 -2
  30. package/lib/packages/hexo-extend-injector2/lib/bundle/handle-data-pre.js +0 -28
  31. package/lib/packages/hexo-extend-injector2/lib/bundle/js-bundle.d.ts +0 -2
  32. package/lib/packages/hexo-extend-injector2/lib/bundle/js-bundle.js +0 -32
  33. package/lib/packages/hexo-extend-injector2/lib/bundle/js-generator.d.ts +0 -2
  34. package/lib/packages/hexo-extend-injector2/lib/bundle/js-generator.js +0 -8
  35. package/lib/packages/hexo-extend-injector2/lib/default-config.d.ts +0 -39
  36. package/lib/packages/hexo-extend-injector2/lib/default-config.js +0 -46
  37. package/lib/packages/hexo-extend-injector2/lib/filter.d.ts +0 -2
  38. package/lib/packages/hexo-extend-injector2/lib/filter.js +0 -22
  39. package/lib/packages/hexo-extend-injector2/lib/helper/injector.d.ts +0 -2
  40. package/lib/packages/hexo-extend-injector2/lib/helper/injector.js +0 -5
  41. package/lib/packages/hexo-extend-injector2/lib/helper/next-inject.d.ts +0 -2
  42. package/lib/packages/hexo-extend-injector2/lib/helper/next-inject.js +0 -12
  43. package/lib/packages/hexo-extend-injector2/lib/injector.d.ts +0 -29
  44. package/lib/packages/hexo-extend-injector2/lib/injector.js +0 -125
  45. package/lib/packages/hexo-extend-injector2/lib/load.d.ts +0 -3
  46. package/lib/packages/hexo-extend-injector2/lib/load.js +0 -37
  47. package/lib/packages/hexo-extend-injector2/lib/next-point.d.ts +0 -2
  48. package/lib/packages/hexo-extend-injector2/lib/next-point.js +0 -18
  49. package/lib/packages/hexo-extend-injector2/lib/next.d.ts +0 -2
  50. package/lib/packages/hexo-extend-injector2/lib/next.js +0 -99
  51. package/lib/packages/hexo-extend-injector2/lib/order.d.ts +0 -5
  52. package/lib/packages/hexo-extend-injector2/lib/order.js +0 -8
  53. package/lib/source/adblock.css +0 -2
  54. package/lib/src/article-ads.d.ts +0 -20
  55. package/lib/src/article-ads.js +0 -304
  56. package/lib/src/checkLocalHost.d.ts +0 -10
  57. package/lib/src/checkLocalHost.js +0 -37
  58. package/lib/src/config.d.ts +0 -13
  59. package/lib/src/config.js +0 -42
  60. package/lib/src/html-parser.d.ts +0 -9
  61. package/lib/src/html-parser.js +0 -26
  62. package/lib/src/log.d.ts +0 -1
  63. package/lib/src/log.js +0 -11
  64. package/lib/src/logger.d.ts +0 -3
  65. package/lib/src/logger.js +0 -25
  66. package/lib/src/md5.d.ts +0 -2
  67. package/lib/src/md5.js +0 -165
  68. package/lib/src/safestringify.d.ts +0 -2
  69. package/lib/src/safestringify.js +0 -125
  70. package/lib/src/utils.d.ts +0 -31
  71. package/lib/src/utils.js +0 -159
  72. package/lib/src/versionParser.d.ts +0 -27
  73. package/lib/src/versionParser.js +0 -40
  74. package/packages/hexo-cli-extras/.eslintrc +0 -13
  75. package/packages/hexo-cli-extras/LICENSE.md +0 -20
  76. package/packages/hexo-cli-extras/README.md +0 -146
  77. package/packages/hexo-cli-extras/docs/basic.gif +0 -0
  78. package/packages/hexo-cli-extras/docs/gui.gif +0 -0
  79. package/packages/hexo-cli-extras/docs/remove.png +0 -0
  80. package/packages/hexo-cli-extras/docs/rename.png +0 -0
  81. package/packages/hexo-cli-extras/index.js +0 -48
  82. package/packages/hexo-cli-extras/lib/edit.js +0 -209
  83. package/packages/hexo-cli-extras/lib/env.js +0 -52
  84. package/packages/hexo-cli-extras/lib/extensions.js +0 -23
  85. package/packages/hexo-cli-extras/lib/integrate.js +0 -87
  86. package/packages/hexo-cli-extras/lib/isolate.js +0 -179
  87. package/packages/hexo-cli-extras/lib/remove.js +0 -145
  88. package/packages/hexo-cli-extras/lib/rename.js +0 -171
  89. package/packages/hexo-cli-extras/package.json +0 -34
  90. package/packages/hexo-extend-injector2/.eslintrc +0 -4
  91. package/packages/hexo-extend-injector2/.github/workflows/linter.yml +0 -27
  92. package/packages/hexo-extend-injector2/.github/workflows/tester.yml +0 -24
  93. package/packages/hexo-extend-injector2/.vscode/settings.json +0 -10
  94. package/packages/hexo-extend-injector2/LICENSE +0 -165
  95. package/packages/hexo-extend-injector2/README-ZH.md +0 -189
  96. package/packages/hexo-extend-injector2/README.md +0 -191
  97. package/packages/hexo-extend-injector2/USAGE.md +0 -38
  98. package/packages/hexo-extend-injector2/index.js +0 -14
  99. package/packages/hexo-extend-injector2/lib/bundle/css-bundle.js +0 -79
  100. package/packages/hexo-extend-injector2/lib/bundle/css-generator.js +0 -13
  101. package/packages/hexo-extend-injector2/lib/bundle/handle-data-pre.js +0 -29
  102. package/packages/hexo-extend-injector2/lib/bundle/js-bundle.js +0 -42
  103. package/packages/hexo-extend-injector2/lib/bundle/js-generator.js +0 -10
  104. package/packages/hexo-extend-injector2/lib/default-config.js +0 -52
  105. package/packages/hexo-extend-injector2/lib/filter.js +0 -24
  106. package/packages/hexo-extend-injector2/lib/helper/injector.js +0 -6
  107. package/packages/hexo-extend-injector2/lib/helper/next-inject.js +0 -14
  108. package/packages/hexo-extend-injector2/lib/injector.js +0 -128
  109. package/packages/hexo-extend-injector2/lib/load.js +0 -45
  110. package/packages/hexo-extend-injector2/lib/next-point.js +0 -19
  111. package/packages/hexo-extend-injector2/lib/next.js +0 -87
  112. package/packages/hexo-extend-injector2/lib/order.js +0 -9
  113. package/packages/hexo-extend-injector2/package.json +0 -49
  114. package/packages/hexo-extend-injector2/renovate.json +0 -6
  115. package/packages/hexo-extend-injector2/test/.eslintrc +0 -3
  116. package/packages/hexo-extend-injector2/test/index.js +0 -18
  117. package/packages/hexo-extend-injector2/test/lib/bundle/bundle-css.js +0 -86
  118. package/packages/hexo-extend-injector2/test/lib/bundle/bundle-js.js +0 -36
  119. package/packages/hexo-extend-injector2/test/lib/bundle/test.css +0 -3
  120. package/packages/hexo-extend-injector2/test/lib/bundle/test.js +0 -5
  121. package/packages/hexo-extend-injector2/test/lib/helper/injector.js +0 -45
  122. package/packages/hexo-extend-injector2/test/lib/helper/next-inject.js +0 -69
  123. package/packages/hexo-extend-injector2/test/lib/hexo-compatible.js +0 -250
  124. package/packages/hexo-extend-injector2/test/lib/hexo-injector.js +0 -37
  125. package/packages/hexo-extend-injector2/test/lib/injector.js +0 -93
  126. package/packages/memoize/CHANGELOG.md +0 -82
  127. package/packages/memoize/CHANGES +0 -124
  128. package/packages/memoize/LICENSE +0 -15
  129. package/packages/memoize/README.md +0 -503
  130. package/packages/memoize/ext/async.js +0 -154
  131. package/packages/memoize/ext/dispose.js +0 -33
  132. package/packages/memoize/ext/max-age.js +0 -90
  133. package/packages/memoize/ext/max.js +0 -27
  134. package/packages/memoize/ext/promise.js +0 -147
  135. package/packages/memoize/ext/ref-counter.js +0 -48
  136. package/packages/memoize/index.js +0 -34
  137. package/packages/memoize/lib/configure-map.js +0 -182
  138. package/packages/memoize/lib/methods.js +0 -32
  139. package/packages/memoize/lib/registered-extensions.js +0 -1
  140. package/packages/memoize/lib/resolve-length.js +0 -15
  141. package/packages/memoize/lib/resolve-normalize.js +0 -17
  142. package/packages/memoize/lib/resolve-resolve.js +0 -21
  143. package/packages/memoize/lib/weak.js +0 -134
  144. package/packages/memoize/methods-plain.js +0 -3
  145. package/packages/memoize/methods.js +0 -3
  146. package/packages/memoize/normalizers/get-1.js +0 -29
  147. package/packages/memoize/normalizers/get-fixed.js +0 -71
  148. package/packages/memoize/normalizers/get-primitive-fixed.js +0 -16
  149. package/packages/memoize/normalizers/get.js +0 -90
  150. package/packages/memoize/normalizers/primitive.js +0 -9
  151. package/packages/memoize/package.json +0 -60
  152. package/packages/memoize/plain.js +0 -37
  153. package/packages/memoize/profile.js +0 -107
  154. package/packages/memoize/repository.md +0 -1
  155. package/packages/memoize/weak-plain.js +0 -3
  156. package/packages/memoize/weak.js +0 -3
  157. package/unused.md +0 -12
package/dist/index.cjs ADDED
@@ -0,0 +1,757 @@
1
+ // hexo-adsense 2.0.0 by Dimas Lanjaka <dimaslanjaka@gmail.com> (https://github.com/dimaslanjaka)
2
+ 'use strict';
3
+
4
+ var fs$2 = require('fs-extra');
5
+ var assign = require('object-assign');
6
+ var path = require('path');
7
+ var prettier = require('prettier');
8
+ var url = require('url');
9
+ var glob = require('glob');
10
+ var fs$1 = require('hexo-fs');
11
+ var fs = require('fs');
12
+ var require$$1 = require('hexo-log');
13
+ var require$$3 = require('util');
14
+ var minimatch = require('minimatch');
15
+ var underscore = require('underscore');
16
+ var minimist = require('minimist');
17
+ var ansiColors = require('ansi-colors');
18
+ var sbgUtility = require('sbg-utility');
19
+ require('bluebird');
20
+
21
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
22
+ function _interopNamespaceDefault(e) {
23
+ var n = Object.create(null);
24
+ if (e) {
25
+ Object.keys(e).forEach(function (k) {
26
+ if (k !== 'default') {
27
+ var d = Object.getOwnPropertyDescriptor(e, k);
28
+ Object.defineProperty(n, k, d.get ? d : {
29
+ enumerable: true,
30
+ get: function () { return e[k]; }
31
+ });
32
+ }
33
+ });
34
+ }
35
+ n.default = e;
36
+ return Object.freeze(n);
37
+ }
38
+
39
+ var prettier__namespace = /*#__PURE__*/_interopNamespaceDefault(prettier);
40
+
41
+ function getDefaultExportFromCjs (x) {
42
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
43
+ }
44
+
45
+ var src = {};
46
+
47
+ var name = "hexo-is";
48
+ var version = "2.0.0";
49
+ var description = "Determine whether hexo is";
50
+ var main = "dist/index.js";
51
+ var types = "dist/index.d.ts";
52
+ var type = "module";
53
+ var module$1 = "dist/index.mjs";
54
+ var exports$1 = {
55
+ ".": {
56
+ require: {
57
+ "default": "./dist/index.cjs",
58
+ types: "./dist/index.d.ts"
59
+ },
60
+ "import": {
61
+ "default": "./dist/index.mjs",
62
+ types: "./dist/index.d.mts"
63
+ }
64
+ }
65
+ };
66
+ var files = [
67
+ "dist/"
68
+ ];
69
+ var scripts = {
70
+ test: "echo \"Error: no test specified\" && exit 1",
71
+ build: "tsc && rollup -c",
72
+ clean: "rimraf dist && npm run build",
73
+ hook: "ts-node hook.ts",
74
+ postbuild: "node packer.js",
75
+ update: "npx npm-check-updates -u -x chalk",
76
+ pack: "node packer.cjs --yarn"
77
+ };
78
+ var keywords = [
79
+ ];
80
+ var repository = {
81
+ type: "git",
82
+ url: "https://github.com/dimaslanjaka/hexo-is.git"
83
+ };
84
+ var homepage = "https://github.com/dimaslanjaka/hexo-seo/tree/master/packages/hexo-is#readme";
85
+ var author = {
86
+ email: "dimaslanjaka@gmail.com",
87
+ name: "Dimas Lanjaka",
88
+ url: "https://github.com/dimaslanjaka"
89
+ };
90
+ var license = "MIT";
91
+ var workspaces = [
92
+ "test/demo",
93
+ "test/demo/themes/*"
94
+ ];
95
+ var dependencies = {
96
+ "fs-extra": "^11.2.0",
97
+ "hexo-log": "^4.1.0",
98
+ minimatch: "^10.0.1",
99
+ "sbg-utility": "^2.0.5",
100
+ upath: "^2.0.1"
101
+ };
102
+ var devDependencies = {
103
+ "@rollup/plugin-commonjs": "^28.0.1",
104
+ "@rollup/plugin-json": "^6.1.0",
105
+ "@rollup/plugin-node-resolve": "^15.3.0",
106
+ "@types/gulp": "^4.0.17",
107
+ "@types/node": "^22.8.4",
108
+ "cross-spawn": "https://github.com/dimaslanjaka/node-cross-spawn/raw/private/release/cross-spawn.tgz",
109
+ "git-command-helper": "^2.0.2",
110
+ gulp: "^5.0.0",
111
+ "gulp-cli": "^3.0.0",
112
+ hexo: "^7.3.0",
113
+ nodemon: "^3.1.7",
114
+ rimraf: "^6.0.1",
115
+ rollup: "^4.24.3",
116
+ "rollup-plugin-dts": "^6.1.1",
117
+ "ts-node": "^10.9.2",
118
+ typescript: "^5.6.3"
119
+ };
120
+ var resolutions = {
121
+ "@types/git-command-helper": "https://github.com/dimaslanjaka/git-command-helper/raw/pre-release/release/git-command-helper.tgz",
122
+ "@types/hexo": "https://github.com/dimaslanjaka/hexo/raw/monorepo-v7/releases/hexo.tgz",
123
+ "binary-collections": "https://github.com/dimaslanjaka/bin/raw/fcd1121/releases/bin.tgz",
124
+ "cross-spawn": "https://github.com/dimaslanjaka/node-cross-spawn/raw/private/release/cross-spawn.tgz",
125
+ "git-command-helper": "https://github.com/dimaslanjaka/git-command-helper/raw/pre-release/release/git-command-helper.tgz",
126
+ hexo: "https://github.com/dimaslanjaka/hexo/raw/monorepo-v7/releases/hexo.tgz",
127
+ "hexo-asset-link": "https://github.com/dimaslanjaka/hexo/raw/monorepo-v7/releases/hexo-asset-link.tgz",
128
+ "hexo-cli": "https://github.com/dimaslanjaka/hexo/raw/monorepo-v7/releases/hexo-cli.tgz",
129
+ "hexo-front-matter": "https://github.com/dimaslanjaka/hexo/raw/monorepo-v7/releases/hexo-front-matter.tgz",
130
+ "hexo-generator-redirect": "https://github.com/dimaslanjaka/hexo-generator-redirect/raw/0885394/release/hexo-generator-redirect.tgz",
131
+ "hexo-log": "https://github.com/dimaslanjaka/hexo/raw/monorepo-v7/releases/hexo-log.tgz",
132
+ "hexo-post-parser": "https://github.com/dimaslanjaka/hexo-post-parser/raw/8c4e98159e4407b77e1c25e028c1fd4a0073a8e3/release/hexo-post-parser.tgz",
133
+ "hexo-renderers": "https://github.com/dimaslanjaka/hexo-renderers/raw/add4a2491075dd85281a5dc0c48b74a7ce51d987/release/hexo-renderers.tgz",
134
+ "hexo-seo": "https://github.com/dimaslanjaka/hexo-seo/raw/f4cf27fbc7de2b831462d3b26cf70ece2499d15b/release/hexo-seo.tgz",
135
+ "hexo-server": "https://github.com/dimaslanjaka/hexo/raw/monorepo-v7/releases/hexo-server.tgz",
136
+ "hexo-shortcodes": "https://github.com/dimaslanjaka/hexo-shortcodes/raw/f70a1c0/release/hexo-shortcodes.tgz",
137
+ "hexo-util": "https://github.com/dimaslanjaka/hexo/raw/monorepo-v7/releases/hexo-util.tgz",
138
+ "instant-indexing": "https://github.com/dimaslanjaka/static-blog-generator/raw/master/packages/instant-indexing/release/instant-indexing.tgz",
139
+ "markdown-it": "https://github.com/dimaslanjaka/markdown-it/raw/17ccc825cbb3e4c6d59edada5f6d93f27075d752/release/markdown-it.tgz",
140
+ "nodejs-package-types": "https://github.com/dimaslanjaka/nodejs-package-types/raw/a2e797bc27975cba20ef4c87547841e6341bfcf4/release/nodejs-package-types.tgz",
141
+ "sbg-api": "https://github.com/dimaslanjaka/static-blog-generator/raw/74a402210be05e3452a386f90b80521e1182a724/packages/sbg-api/release/sbg-api.tgz",
142
+ "sbg-cli": "https://github.com/dimaslanjaka/static-blog-generator/raw/0164b0d2e4ba5453890af8ec4863b2a09e043815/packages/sbg-cli/release/sbg-cli.tgz",
143
+ "sbg-server": "https://github.com/dimaslanjaka/static-blog-generator/raw/master/packages/sbg-server/release/sbg-server.tgz",
144
+ "sbg-utility": "https://github.com/dimaslanjaka/static-blog-generator/raw/c7e82cae850b9fd6c1829ff6d30ef3ee8987019b/packages/sbg-utility/release/sbg-utility.tgz",
145
+ "static-blog-generator": "https://github.com/dimaslanjaka/static-blog-generator/raw/master/packages/static-blog-generator/release/static-blog-generator.tgz",
146
+ warehouse: "https://github.com/dimaslanjaka/hexo/raw/monorepo-v7/releases/warehouse.tgz"
147
+ };
148
+ var packageManager = "yarn@4.5.1";
149
+ var require$$4 = {
150
+ name: name,
151
+ version: version,
152
+ description: description,
153
+ main: main,
154
+ types: types,
155
+ type: type,
156
+ module: module$1,
157
+ exports: exports$1,
158
+ files: files,
159
+ scripts: scripts,
160
+ keywords: keywords,
161
+ repository: repository,
162
+ homepage: homepage,
163
+ author: author,
164
+ license: license,
165
+ workspaces: workspaces,
166
+ dependencies: dependencies,
167
+ devDependencies: devDependencies,
168
+ resolutions: resolutions,
169
+ packageManager: packageManager
170
+ };
171
+
172
+ var is = {};
173
+
174
+ /* eslint-disable @typescript-eslint/no-this-alias */
175
+
176
+ var hasRequiredIs;
177
+
178
+ function requireIs () {
179
+ if (hasRequiredIs) return is;
180
+ hasRequiredIs = 1;
181
+ (function (exports) {
182
+ Object.defineProperty(exports, "__esModule", { value: true });
183
+ exports.tag = exports.category = exports.month = exports.year = exports.archive = exports.page = exports.post = exports.home = exports.current = void 0;
184
+ exports.default = internalIs;
185
+ function isCurrentHelper(path, strict) {
186
+ if (path === void 0) { path = "/"; }
187
+ var currentPath = this.path.replace(/^[^/].*/, "/$&");
188
+ if (strict) {
189
+ if (path.endsWith("/"))
190
+ path += "index.html";
191
+ path = path.replace(/^[^/].*/, "/$&");
192
+ return currentPath === path;
193
+ }
194
+ path = path.replace(/\/index\.html$/, "/");
195
+ if (path === "/")
196
+ return currentPath === "/index.html";
197
+ path = path.replace(/^[^/].*/, "/$&");
198
+ return currentPath.startsWith(path);
199
+ }
200
+ function isHomeHelper() {
201
+ return Boolean(this.page.__index);
202
+ }
203
+ function isPostHelper() {
204
+ if (this.page) {
205
+ var src = this.page["full_source"] || "";
206
+ var layout = this.page.layout || "";
207
+ if (layout.startsWith("post"))
208
+ return true;
209
+ if (layout.startsWith("page"))
210
+ return false;
211
+ if (src !== "") {
212
+ return Boolean(this.page.__post) && src.includes("_posts");
213
+ }
214
+ }
215
+ return Boolean(this.page.__post);
216
+ }
217
+ function isPageHelper() {
218
+ if (this.page) {
219
+ var src = this.page["full_source"] || "";
220
+ var layout = this.page.layout || "";
221
+ if (layout.startsWith("post"))
222
+ return false;
223
+ if (layout.startsWith("page"))
224
+ return true;
225
+ if (src !== "") {
226
+ return Boolean(this.page.__post) && !src.includes("_posts");
227
+ }
228
+ }
229
+ return Boolean(this.page.__page);
230
+ }
231
+ function isArchiveHelper() {
232
+ return Boolean(this.page.archive);
233
+ }
234
+ function isYearHelper(year) {
235
+ var page = this.page;
236
+ if (!page.archive)
237
+ return false;
238
+ if (year) {
239
+ return page.year === year;
240
+ }
241
+ return Boolean(page.year);
242
+ }
243
+ function isMonthHelper(year, month) {
244
+ var page = this.page;
245
+ if (!page.archive)
246
+ return false;
247
+ if (year) {
248
+ if (month) {
249
+ return page.year === year && page.month === month;
250
+ }
251
+ return page.month === year;
252
+ }
253
+ return Boolean(page.year && page.month);
254
+ }
255
+ function isCategoryHelper(category) {
256
+ if (category) {
257
+ return this.page.category === category;
258
+ }
259
+ return Boolean(this.page.category);
260
+ }
261
+ function isTagHelper(tag) {
262
+ if (tag) {
263
+ return this.page.tag === tag;
264
+ }
265
+ return Boolean(this.page.tag);
266
+ }
267
+ exports.current = isCurrentHelper;
268
+ exports.home = isHomeHelper;
269
+ exports.post = isPostHelper;
270
+ exports.page = isPageHelper;
271
+ exports.archive = isArchiveHelper;
272
+ exports.year = isYearHelper;
273
+ exports.month = isMonthHelper;
274
+ exports.category = isCategoryHelper;
275
+ exports.tag = isTagHelper;
276
+ /**
277
+ * Custom function
278
+ * @param hexo
279
+ * @returns
280
+ */
281
+ function internalIs(hexo) {
282
+ var obj = {
283
+ current: false,
284
+ home: false,
285
+ post: false,
286
+ page: false,
287
+ archive: false,
288
+ year: false,
289
+ month: false,
290
+ category: false,
291
+ tag: false,
292
+ message: "try using second argument",
293
+ };
294
+ if (typeof hexo["page"] == "undefined")
295
+ return obj;
296
+ return {
297
+ current: exports.current.bind(hexo)(),
298
+ home: exports.home.bind(hexo)(),
299
+ post: exports.post.bind(hexo)(),
300
+ page: exports.page.bind(hexo)(),
301
+ archive: exports.archive.bind(hexo)(),
302
+ year: exports.year.bind(hexo)(),
303
+ month: exports.month.bind(hexo)(),
304
+ category: exports.category.bind(hexo)(),
305
+ tag: exports.tag.bind(hexo)(),
306
+ };
307
+ }
308
+ } (is));
309
+ return is;
310
+ }
311
+
312
+ var hasRequiredSrc;
313
+
314
+ function requireSrc () {
315
+ if (hasRequiredSrc) return src;
316
+ hasRequiredSrc = 1;
317
+ (function (exports) {
318
+ var __createBinding = (src && src.__createBinding) || (Object.create ? (function(o, m, k, k2) {
319
+ if (k2 === undefined) k2 = k;
320
+ var desc = Object.getOwnPropertyDescriptor(m, k);
321
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
322
+ desc = { enumerable: true, get: function() { return m[k]; } };
323
+ }
324
+ Object.defineProperty(o, k2, desc);
325
+ }) : (function(o, m, k, k2) {
326
+ if (k2 === undefined) k2 = k;
327
+ o[k2] = m[k];
328
+ }));
329
+ var __setModuleDefault = (src && src.__setModuleDefault) || (Object.create ? (function(o, v) {
330
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
331
+ }) : function(o, v) {
332
+ o["default"] = v;
333
+ });
334
+ var __importStar = (src && src.__importStar) || function (mod) {
335
+ if (mod && mod.__esModule) return mod;
336
+ var result = {};
337
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
338
+ __setModuleDefault(result, mod);
339
+ return result;
340
+ };
341
+ var __importDefault = (src && src.__importDefault) || function (mod) {
342
+ return (mod && mod.__esModule) ? mod : { "default": mod };
343
+ };
344
+ Object.defineProperty(exports, "__esModule", { value: true });
345
+ exports.hexoIs = void 0;
346
+ exports.hexoIsDump = hexoIsDump;
347
+ /* eslint-disable prefer-rest-params */
348
+ var fs$1 = __importStar(fs);
349
+ var hexo_log_1 = __importDefault(require$$1);
350
+ var path_1 = __importDefault(path);
351
+ var util_1 = __importDefault(require$$3);
352
+ var package_json_1 = __importDefault(require$$4);
353
+ var is_1 = __importDefault(requireIs());
354
+ var log = (0, hexo_log_1.default)({
355
+ debug: false,
356
+ silent: false,
357
+ });
358
+ /**
359
+ * @example
360
+ * // run inside plugin or theme event
361
+ * import hexoIs from 'hexo-is';
362
+ * const hexo = this;
363
+ * console.log(hexoIs(hexo)); // object or string
364
+ * @param hexo
365
+ * @returns
366
+ */
367
+ var hexoIs = function (hexo) {
368
+ if (typeof hexo === "undefined")
369
+ return;
370
+ if (typeof hexo["page"] != "undefined")
371
+ return (0, is_1.default)(hexo);
372
+ if (typeof hexo["type"] != "undefined") {
373
+ var ix = (0, is_1.default)(hexo);
374
+ if (typeof ix[hexo["type"]] != "undefined")
375
+ ix[hexo["type"]] = true;
376
+ return ix;
377
+ }
378
+ };
379
+ exports.hexoIs = hexoIs;
380
+ /**
381
+ * Dump variable to file
382
+ * @param toDump
383
+ */
384
+ function hexoIsDump(toDump, name) {
385
+ if (name === void 0) { name = ""; }
386
+ if (name.length > 0)
387
+ name = "-" + name;
388
+ var dump = util_1.default.inspect(toDump, { showHidden: true, depth: null });
389
+ var loc = path_1.default.join("tmp/hexo-is/dump" + name + ".txt");
390
+ if (!fs$1.existsSync(path_1.default.dirname(loc))) {
391
+ fs$1.mkdirSync(path_1.default.dirname(loc), { recursive: true });
392
+ }
393
+ fs$1.writeFileSync(loc, dump);
394
+ log.log("".concat(package_json_1.default.name, ": dump saved to: ").concat(path_1.default.resolve(loc)));
395
+ }
396
+ exports.default = exports.hexoIs;
397
+ } (src));
398
+ return src;
399
+ }
400
+
401
+ var srcExports = requireSrc();
402
+ var index = /*@__PURE__*/getDefaultExportFromCjs(srcExports);
403
+
404
+ const argv = minimist(process.argv.slice(2));
405
+ /**
406
+ * Check if the environment is production or development
407
+ * @param inHexo Hexo instance
408
+ * @returns Environment
409
+ */
410
+ const getEnv = underscore.memoize((inHexo) => {
411
+ const DEV = 'development';
412
+ const PRD = 'production';
413
+ // Check if --development flag is set
414
+ const arg = typeof argv['development'] === 'boolean' && argv['development'];
415
+ // Check if NODE_ENV is set to "development"
416
+ const env = process.env.NODE_ENV?.toLowerCase() === 'development';
417
+ // Determine if environment is development
418
+ const isDev = arg || env;
419
+ if (inHexo) {
420
+ if (isDev)
421
+ return DEV;
422
+ if (typeof inHexo.env.args.development === 'boolean' && inHexo.env.args.development)
423
+ return DEV;
424
+ if (inHexo.env.args._ && inHexo.env.args._.length > 0) {
425
+ for (const arg of inHexo.env.args._) {
426
+ if (arg === 's' || arg === 'server')
427
+ return DEV;
428
+ if (arg === 'd' || arg === 'deploy')
429
+ return PRD;
430
+ if (arg === 'g' || arg === 'generate')
431
+ return PRD;
432
+ }
433
+ }
434
+ }
435
+ return null;
436
+ });
437
+ /**
438
+ * Determine if the environment is development
439
+ * @param hexo Hexo instance
440
+ * @returns boolean
441
+ */
442
+ const isDev = underscore.memoize((hexo) => getEnv(hexo) === 'development');
443
+ /**
444
+ * Determine if the environment is production
445
+ * @param hexo Hexo instance
446
+ * @returns boolean
447
+ */
448
+ underscore.memoize((hexo) => getEnv(hexo) === 'production');
449
+ const defaultConfig = {
450
+ enable: true,
451
+ article_ads: [''].filter((v) => typeof v === 'string' && v.length > 0),
452
+ pub: '',
453
+ adblock: false,
454
+ https: false,
455
+ field: 'site',
456
+ type: 'javascript',
457
+ exclude: ['.gitignore'],
458
+ development: false
459
+ };
460
+ /**
461
+ * hexo-adsense config
462
+ * @param hexo
463
+ * @returns
464
+ */
465
+ function getHexoAdsenseConfig(hexo) {
466
+ if (typeof hexo.config.adsense !== 'undefined') {
467
+ if (typeof hexo.config.adsense === 'boolean') {
468
+ // fix when adsense: false
469
+ hexo.config.adsense = {};
470
+ hexo.config.adsense.enable = hexo.config.adsense;
471
+ }
472
+ const config = assign(defaultConfig, hexo.config.adsense);
473
+ config.development = defaultConfig.development = isDev(hexo);
474
+ return config;
475
+ }
476
+ return defaultConfig;
477
+ }
478
+
479
+ const logname = ansiColors.magentaBright('hexo-adsense');
480
+ const once = (function (...fn) {
481
+ let executed = false;
482
+ return function () {
483
+ if (!executed) {
484
+ executed = true;
485
+ // Do something
486
+ if (typeof fn[0] === 'function')
487
+ return fn[0]();
488
+ console.log(fn);
489
+ }
490
+ };
491
+ })();
492
+ function stack(msg) {
493
+ const logLineDetails = new Error().stack?.split('at ')[3].trim();
494
+ console.log('DEBUG', new Date().toUTCString(), logLineDetails, msg);
495
+ }
496
+ const defaultLogger = typeof hexo !== 'undefined' ? hexo.log : require$$1({ silent: false, debug: true });
497
+ const logger = {
498
+ stack,
499
+ once
500
+ };
501
+ const debugLog = function (...args) {
502
+ sbgUtility.debug('hexo-adsense')(...args);
503
+ defaultLogger.debug(logname, ...args);
504
+ };
505
+ var logger$1 = Object.assign(defaultLogger, logger);
506
+
507
+ // ESM-compatible __dirname replacement
508
+ path.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))));
509
+ /**
510
+ * @param path0
511
+ * @param exclude
512
+ * @param hexo
513
+ * @returns boolean
514
+ */
515
+ const isIgnore = (path0, exclude, hexo) => {
516
+ if (exclude && !Array.isArray(exclude))
517
+ exclude = [exclude];
518
+ if (path0 && exclude && exclude.length) {
519
+ for (let i = 0, len = exclude.length; i < len; i++) {
520
+ const excludePattern = exclude[i];
521
+ if (hexo) {
522
+ const fromBase = sbgUtility.normalizePathUnix(hexo.base_dir, excludePattern);
523
+ const fromSource = sbgUtility.normalizePathUnix(hexo.source_dir, excludePattern);
524
+ if (minimatch.minimatch(path0, fromSource))
525
+ return true;
526
+ if (minimatch.minimatch(path0, fromBase))
527
+ return true;
528
+ }
529
+ if (minimatch.minimatch(path0, excludePattern))
530
+ return true;
531
+ }
532
+ }
533
+ return false;
534
+ };
535
+ const tmpFolder = sbgUtility.normalizePath(typeof hexo !== 'undefined' ? hexo.base_dir : process.cwd(), 'tmp/hexo-adsense');
536
+
537
+ // ESM-compatible __dirname replacement
538
+ const __dirname$2 = path.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))));
539
+ const adsContent = `<div hexo-adsense="ads-content">ADS_CODE_HERE</div>`;
540
+ String.prototype.joinpath = function (str) {
541
+ return path.join(this.toString(), str);
542
+ };
543
+ function parseConfig(hexo) {
544
+ return getHexoAdsenseConfig(hexo);
545
+ }
546
+ function articleAds(files, hexo) {
547
+ const base_dir = hexo.base_dir;
548
+ const source_dir = hexo.source_dir;
549
+ const isDevelopment = parseConfig(hexo).development;
550
+ const result = [];
551
+ files.forEach((file) => {
552
+ let html = '';
553
+ let tes = base_dir.joinpath(file);
554
+ if (fs$1.existsSync(tes)) {
555
+ html = fs$1.readFileSync(tes).toString();
556
+ }
557
+ else {
558
+ tes = source_dir.joinpath(file);
559
+ if (fs$1.existsSync(tes)) {
560
+ html = fs$1.readFileSync(tes).toString();
561
+ }
562
+ }
563
+ if (html.length > 0) {
564
+ if (isDevelopment) {
565
+ html = html.replace(/><\/ins>/gm, ` data-adtest="on"></ins>`);
566
+ }
567
+ html = html.replace(/\(adsbygoogle?\s*=?\s*window\.adsbygoogle?\s*\|\|?\s*\[\]\)\.push\({}\);/gm, '');
568
+ html = html.replace(/<script?.*src?.*adsbygoogle\b[^>]*>([\s\S]*?)<\/script>/gm, '');
569
+ result.push(adsContent.replace('ADS_CODE_HERE', html));
570
+ }
571
+ });
572
+ return result;
573
+ }
574
+ function filter_adshtml(hexo) {
575
+ const options = parseConfig(hexo);
576
+ let adshtml = [];
577
+ if (Array.isArray(options.article_ads)) {
578
+ // array of file paths
579
+ adshtml = options.article_ads;
580
+ }
581
+ else if (typeof options.article_ads === 'string') {
582
+ // single file path
583
+ adshtml = [options.article_ads];
584
+ }
585
+ else if (typeof options.article_ads === 'boolean') {
586
+ // scan source_dir/_data/hexo-adsense/*.html
587
+ adshtml = glob.globSync([`${hexo.config.source_dir}/ads/**/*.html`, `${hexo.config.source_dir}/_data/hexo-adsense/**/*.html`], {
588
+ cwd: hexo.base_dir
589
+ });
590
+ }
591
+ if (adshtml.length > 0) {
592
+ adshtml = adshtml.filter((ads) => typeof ads === 'string' && ads.trim().length > 0);
593
+ if (adshtml.length > 0) {
594
+ adshtml = articleAds(adshtml, hexo);
595
+ }
596
+ }
597
+ return adshtml;
598
+ }
599
+ function filter_patterns(content, source_path, hexo) {
600
+ const options = parseConfig(hexo);
601
+ const excluded = isIgnore(source_path, options.exclude, hexo);
602
+ if (excluded) {
603
+ content = content.replace(/<script?.*src?.*adsbygoogle?\b[^>]*>([\s\S]*?)<\/script>/gm, '<!--hexo-adsense disabled on this page-->');
604
+ }
605
+ return {
606
+ content,
607
+ excluded
608
+ };
609
+ }
610
+ function after_post_render(data) {
611
+ const hexo = this;
612
+ const options = parseConfig(hexo);
613
+ const filterPattern = filter_patterns(data.content, getPageSource(data), hexo);
614
+ data.content = filterPattern.content;
615
+ if (filterPattern.excluded)
616
+ return data;
617
+ const adshtml = filter_adshtml(hexo);
618
+ if (adshtml.length < 1)
619
+ return data;
620
+ if (typeof data.adsense === 'boolean' && data.adsense) {
621
+ data.content = processAdsHtml(data.content, adshtml, hexo);
622
+ }
623
+ else if (options.enable) {
624
+ data.content = processAdsHtml(data.content, adshtml, hexo);
625
+ }
626
+ return data;
627
+ }
628
+ function processAdsHtml(content, adshtml, hexo) {
629
+ const options = parseConfig(hexo);
630
+ const replacement = underscore.memoize((adshtml) => {
631
+ const adsContentCss = path.join(__dirname$2, 'source/article-ads.css');
632
+ const adsContentJs = path.join(__dirname$2, 'source/article-ads.js');
633
+ let replacement = `<div id="hexo-adsense-hidden" style="display:none">${adshtml.join('')}</div>`;
634
+ if (fs$1.existsSync(adsContentCss))
635
+ replacement += `<style>${fs$1.readFileSync(adsContentCss).toString()}</style>`;
636
+ if (fs$1.existsSync(adsContentJs))
637
+ replacement += `<script>${fs$1.readFileSync(adsContentJs).toString()}</script>`;
638
+ return replacement;
639
+ });
640
+ const caller = new Error().stack?.split('at ')[2].replace(/^Hexo./g, '');
641
+ const isFieldPost = caller?.startsWith('after_post_render');
642
+ if (isFieldPost) {
643
+ content += replacement(adshtml);
644
+ }
645
+ else {
646
+ if (!options.enable) {
647
+ content = content.replace(/<\/head>/gm, `<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${options.pub}" crossorigin="anonymous"></script>`);
648
+ }
649
+ content = content.replace(/<\/body>/gm, `${replacement(adshtml)}</body>`);
650
+ }
651
+ return content;
652
+ }
653
+ function getPageSource(page) {
654
+ return page.full_source || page.source || page.path || page.canonical_path;
655
+ }
656
+ function after_render_html(content, data) {
657
+ const hexo = this;
658
+ const options = parseConfig(hexo);
659
+ const where = index(data);
660
+ const page = data.post ?? data.page;
661
+ const isPageAdsenseEnabled = typeof page.adsense === 'boolean' ? page.adsense : options.enable;
662
+ if (options.field === 'post') {
663
+ if (where.category || where.archive || where.home || where.tag) {
664
+ debugLog(`config field for post, skipping ${data.path || '<empty path>'}`);
665
+ return content;
666
+ }
667
+ }
668
+ debugLog(page.path, 'is adsense enabled', isPageAdsenseEnabled);
669
+ if (isPageAdsenseEnabled) {
670
+ const filterPattern = filter_patterns(content, getPageSource(page), hexo);
671
+ if (filterPattern.excluded)
672
+ return filterPattern.content;
673
+ const adshtml = filter_adshtml(hexo);
674
+ if (adshtml.length < 1)
675
+ return content;
676
+ if (page.adsense || options.enable) {
677
+ content = processAdsHtml(content, adshtml, hexo);
678
+ }
679
+ const pageAd = `<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${options.pub}" crossorigin="anonymous"></script>`;
680
+ content = content.replace(/<\/head>/, pageAd + '</head>');
681
+ }
682
+ return content;
683
+ }
684
+
685
+ /* global hexo */
686
+ // ESM-compatible __dirname replacement
687
+ const __dirname$1 = path.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))));
688
+ if (typeof hexo !== 'undefined' && typeof hexo.config.adsense !== 'undefined') {
689
+ // const injector = injector2(hexo); // Create injector plugin
690
+ const config = getHexoAdsenseConfig(hexo);
691
+ const isDevelopment = config.development;
692
+ // clean temp folder on `hexo clean`
693
+ hexo.extend.filter.register('after_clean', function () {
694
+ // remove some other temporary files
695
+ hexo.log.debug(logname + '(clean)', 'cleaning temp folder');
696
+ if (fs$2.existsSync(tmpFolder))
697
+ fs$2.rmSync(tmpFolder, { recursive: true, force: true });
698
+ });
699
+ if (config.pub.length < 1) {
700
+ logger$1.error(logname + '(config)', `adsense ca-pub (adsense.pub) not configured in _config.yml`);
701
+ }
702
+ else {
703
+ if (config.enable) {
704
+ // Write config on </head>
705
+ // injector.register('head_end', function () {
706
+ // const adsenseConfigObject = JSON.stringify(
707
+ // assign(config, hexo.env, { adsense: hexo.config.adsense }),
708
+ // null,
709
+ // isDevelopment ? 2 : undefined
710
+ // );
711
+ // return `<script id="hexo-adsense-config" type="application/json">${adsenseConfigObject}</script>`;
712
+ // });
713
+ hexo.extend.filter.register('after_render:html', function (content, _data) {
714
+ const lastBodyRegex = /<\/body>(?=[^<]*$)/;
715
+ const firstHeadRegex = /<\/head>/;
716
+ const adsenseConfigObject = JSON.stringify(assign(config, hexo.env, { adsense: hexo.config.adsense }), null, isDevelopment ? 2 : undefined);
717
+ const script = `<script id="hexo-adsense-config" type="application/json">${adsenseConfigObject}</script>`;
718
+ // Apply functions only in production
719
+ if (!isDevelopment) {
720
+ // Redirect to HTTPS if configured
721
+ if (typeof config.https === 'boolean' && config.https) {
722
+ const https_js = fs$2.readFileSync(path.join(__dirname$1, 'source/https.js'), 'utf-8');
723
+ content = content.replace(lastBodyRegex, `<script>${https_js}</script></body>`);
724
+ }
725
+ // Add adblock blocker if configured
726
+ if (typeof config.adblock === 'boolean' && config.adblock) {
727
+ const adblock_css = fs$2.readFileSync(path.join(__dirname$1, 'source/adblock.css'), 'utf-8');
728
+ const adblock_js = fs$2.readFileSync(path.join(__dirname$1, 'source/adblock.js'), 'utf-8');
729
+ content = content.replace(lastBodyRegex, `<style>${adblock_css}</style><script>${adblock_js}</script></body>`);
730
+ }
731
+ }
732
+ return content.replace(firstHeadRegex, script + '</head>');
733
+ });
734
+ // Handle article ads if configured
735
+ if (typeof config.article_ads !== 'undefined') {
736
+ if (config.field === 'post') {
737
+ logger$1.info(logname, 'apply adsense only for posts');
738
+ // Apply to posts
739
+ hexo.extend.filter.register('after_post_render', after_post_render);
740
+ }
741
+ else {
742
+ logger$1.info(logname, 'apply adsense for all sites pages and posts');
743
+ // Apply to entire HTML
744
+ hexo.extend.filter.register('after_render:html', after_render_html);
745
+ }
746
+ }
747
+ // Prettify on development
748
+ if (hexo.env.cmd === 'server' && isDevelopment) {
749
+ hexo.extend.filter.register('after_render:html', async function (content, _page) {
750
+ const format = await prettier__namespace.format(content, { parser: 'html' });
751
+ debugLog(`Prettier formatted html result of ${_page.path}`);
752
+ return format;
753
+ });
754
+ }
755
+ }
756
+ }
757
+ }