hexo-adsense 1.0.21 → 1.0.25

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 (99) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +20 -6
  3. package/lib/index.js +8 -1
  4. package/lib/source/adblock.css +2 -83
  5. package/lib/source/adblock.js +1 -31
  6. package/lib/source/article-ads.css +2 -11
  7. package/lib/source/article-ads.js +1 -270
  8. package/lib/source/blogger-redirect.html +1 -14
  9. package/lib/source/https.js +1 -4
  10. package/lib/src/article-ads.d.ts +1 -1
  11. package/lib/src/article-ads.js +6 -6
  12. package/lib/src/config.d.ts +12 -19
  13. package/lib/src/config.js +3 -5
  14. package/lib/src/utils.d.ts +9 -1
  15. package/lib/src/utils.js +2 -2
  16. package/package.json +20 -5
  17. package/packages/hexo-cli-extras/.eslintrc +13 -0
  18. package/packages/hexo-cli-extras/LICENSE.md +20 -0
  19. package/packages/hexo-cli-extras/README.md +146 -0
  20. package/packages/hexo-cli-extras/docs/basic.gif +0 -0
  21. package/packages/hexo-cli-extras/docs/gui.gif +0 -0
  22. package/packages/hexo-cli-extras/docs/remove.png +0 -0
  23. package/packages/hexo-cli-extras/docs/rename.png +0 -0
  24. package/packages/hexo-cli-extras/index.js +48 -0
  25. package/packages/hexo-cli-extras/lib/edit.js +209 -0
  26. package/packages/hexo-cli-extras/lib/env.js +52 -0
  27. package/packages/hexo-cli-extras/lib/extensions.js +23 -0
  28. package/packages/hexo-cli-extras/lib/integrate.js +87 -0
  29. package/packages/hexo-cli-extras/lib/isolate.js +179 -0
  30. package/packages/hexo-cli-extras/lib/remove.js +145 -0
  31. package/packages/hexo-cli-extras/lib/rename.js +171 -0
  32. package/packages/hexo-cli-extras/package.json +34 -0
  33. package/packages/hexo-extend-injector2/.eslintrc +4 -0
  34. package/packages/hexo-extend-injector2/.github/workflows/linter.yml +27 -0
  35. package/packages/hexo-extend-injector2/.github/workflows/tester.yml +24 -0
  36. package/packages/hexo-extend-injector2/.vscode/settings.json +10 -0
  37. package/packages/hexo-extend-injector2/LICENSE +165 -0
  38. package/packages/hexo-extend-injector2/README-ZH.md +189 -0
  39. package/packages/hexo-extend-injector2/README.md +191 -0
  40. package/packages/hexo-extend-injector2/USAGE.md +38 -0
  41. package/packages/hexo-extend-injector2/index.js +13 -0
  42. package/packages/hexo-extend-injector2/lib/bundle/css-bundle.js +79 -0
  43. package/packages/hexo-extend-injector2/lib/bundle/css-generator.js +13 -0
  44. package/packages/hexo-extend-injector2/lib/bundle/handle-data-pre.js +29 -0
  45. package/packages/hexo-extend-injector2/lib/bundle/js-bundle.js +42 -0
  46. package/packages/hexo-extend-injector2/lib/bundle/js-generator.js +10 -0
  47. package/packages/hexo-extend-injector2/lib/default-config.js +52 -0
  48. package/packages/hexo-extend-injector2/lib/filter.js +24 -0
  49. package/packages/hexo-extend-injector2/lib/helper/injector.js +6 -0
  50. package/packages/hexo-extend-injector2/lib/helper/next-inject.js +14 -0
  51. package/packages/hexo-extend-injector2/lib/injector.js +128 -0
  52. package/packages/hexo-extend-injector2/lib/load.js +45 -0
  53. package/packages/hexo-extend-injector2/lib/next-point.js +19 -0
  54. package/packages/hexo-extend-injector2/lib/next.js +87 -0
  55. package/packages/hexo-extend-injector2/lib/order.js +9 -0
  56. package/packages/hexo-extend-injector2/package.json +49 -0
  57. package/packages/hexo-extend-injector2/renovate.json +6 -0
  58. package/packages/hexo-extend-injector2/test/.eslintrc +3 -0
  59. package/packages/hexo-extend-injector2/test/index.js +18 -0
  60. package/packages/hexo-extend-injector2/test/lib/bundle/bundle-css.js +86 -0
  61. package/packages/hexo-extend-injector2/test/lib/bundle/bundle-js.js +36 -0
  62. package/packages/hexo-extend-injector2/test/lib/bundle/test.css +3 -0
  63. package/packages/hexo-extend-injector2/test/lib/bundle/test.js +5 -0
  64. package/packages/hexo-extend-injector2/test/lib/helper/injector.js +45 -0
  65. package/packages/hexo-extend-injector2/test/lib/helper/next-inject.js +69 -0
  66. package/packages/hexo-extend-injector2/test/lib/hexo-compatible.js +250 -0
  67. package/packages/hexo-extend-injector2/test/lib/hexo-injector.js +37 -0
  68. package/packages/hexo-extend-injector2/test/lib/injector.js +93 -0
  69. package/packages/memoize/CHANGELOG.md +82 -0
  70. package/packages/memoize/CHANGES +124 -0
  71. package/packages/memoize/LICENSE +15 -0
  72. package/packages/memoize/README.md +503 -0
  73. package/packages/memoize/ext/async.js +154 -0
  74. package/packages/memoize/ext/dispose.js +33 -0
  75. package/packages/memoize/ext/max-age.js +90 -0
  76. package/packages/memoize/ext/max.js +27 -0
  77. package/packages/memoize/ext/promise.js +147 -0
  78. package/packages/memoize/ext/ref-counter.js +48 -0
  79. package/packages/memoize/index.js +34 -0
  80. package/packages/memoize/lib/configure-map.js +182 -0
  81. package/packages/memoize/lib/methods.js +32 -0
  82. package/packages/memoize/lib/registered-extensions.js +1 -0
  83. package/packages/memoize/lib/resolve-length.js +15 -0
  84. package/packages/memoize/lib/resolve-normalize.js +17 -0
  85. package/packages/memoize/lib/resolve-resolve.js +21 -0
  86. package/packages/memoize/lib/weak.js +134 -0
  87. package/packages/memoize/methods-plain.js +3 -0
  88. package/packages/memoize/methods.js +3 -0
  89. package/packages/memoize/normalizers/get-1.js +29 -0
  90. package/packages/memoize/normalizers/get-fixed.js +71 -0
  91. package/packages/memoize/normalizers/get-primitive-fixed.js +16 -0
  92. package/packages/memoize/normalizers/get.js +90 -0
  93. package/packages/memoize/normalizers/primitive.js +9 -0
  94. package/packages/memoize/package.json +60 -0
  95. package/packages/memoize/plain.js +37 -0
  96. package/packages/memoize/profile.js +107 -0
  97. package/packages/memoize/repository.md +1 -0
  98. package/packages/memoize/weak-plain.js +3 -0
  99. package/packages/memoize/weak.js +3 -0
@@ -1,270 +1 @@
1
- /**
2
- * Browser processor
3
- */
4
-
5
- const isBrowser = new Function("try {return this===window;}catch(e){ return false;}");
6
-
7
- /**
8
- * @type {import("../src/config")}
9
- */
10
- const hexoAdsenseConfig = JSON.parse(document.getElementById("hexo-adsense-config").textContent);
11
- //console.log(hexoAdsenseConfig);
12
-
13
- /**
14
- * Insert after element
15
- * @param {HTMLElement} newElement
16
- * @param {HTMLElement} oldElement
17
- */
18
- function insertAfter(newElement, oldElement) {
19
- if (oldElement && newElement) {
20
- let parent = oldElement.parentNode;
21
- if (parent.lastChild == oldElement) {
22
- parent.appendChild(newElement);
23
- } else {
24
- parent.insertBefore(newElement, oldElement.nextSibling);
25
- }
26
- } else {
27
- console.error("cannot insert element");
28
- }
29
- }
30
-
31
- /**
32
- * Replace elements with new
33
- * @param {HTMLElement} newElement
34
- * @param {HTMLElement} oldElement
35
- */
36
- function replaceWith(newElement, oldElement) {
37
- if (!oldElement.parentNode) {
38
- console.log(oldElement, "parent null");
39
- let d = document.createElement("div");
40
- d.appendChild(oldElement);
41
- } else {
42
- //console.log(oldElement.parentNode.tagName);
43
- oldElement.parentNode.replaceChild(newElement, oldElement);
44
- }
45
- /*
46
- try {
47
- oldElement.parentNode.replaceChild(newElement, oldElement);
48
- } catch (e) {}
49
- */
50
- }
51
-
52
- let createElementFromHTML = function (htmlString) {
53
- if (htmlString instanceof HTMLElement) {
54
- return htmlString;
55
- }
56
- var div = document.createElement("div");
57
- div.innerHTML = htmlString.trim();
58
-
59
- // Change this to div.childNodes to support multiple top-level nodes
60
- return div.firstChild;
61
- };
62
-
63
- function oldMethod() {
64
- let article = document.getElementsByTagName("article");
65
- let adscont = document.getElementById("hexo-adsense-ads-content");
66
- if (adscont && adscont.length) {
67
- if (article && article.length) {
68
- let linebreak = article.item(0).getElementsByTagName("br");
69
- if (linebreak.length > 0) {
70
- return replaceWith(adscont, linebreak.item(0));
71
- }
72
-
73
- let headings = article.item(0).querySelectorAll("h2,h3,h4,h5");
74
- if (headings && headings.length > 0) {
75
- return insertAfter(adscont, headings.item(0));
76
- }
77
- }
78
- }
79
- }
80
-
81
- /**
82
- * random number between min and max
83
- */
84
- function ranumb(min, max) {
85
- // min and max included
86
- return Math.floor(Math.random() * (max - min + 1) + min);
87
- }
88
-
89
- function newMethod() {
90
- const adshide = document.getElementById("hexo-adsense-hidden");
91
- let adscont = adshide.querySelectorAll('[hexo-adsense="ads-content"]');
92
- const article = document.querySelectorAll("article");
93
- if (article.length > 0 && adscont.length > 0) {
94
- /**
95
- * @type {HTMLElement}
96
- */
97
- let ads;
98
- if (article.length == 1) {
99
- console.log("webpage is post");
100
- let targetArticle = article.item(0);
101
-
102
- // prioritize hexo-adsense-fill before auto ads on other elements
103
- const ads_fill = targetArticle.querySelectorAll("*[hexo-adsense-fill]");
104
- if (ads_fill.length > 0) {
105
- for (let index = 0; index < ads_fill.length; index++) {
106
- const toFill = ads_fill[index];
107
- if (typeof adscont[index] !== "undefined") {
108
- toFill.appendChild(adscont[index]);
109
- }
110
- }
111
- }
112
-
113
- // the rest of the ads will show automatically after headers, pre elements
114
- adscont = adshide.querySelectorAll('[hexo-adsense="ads-content"]');
115
- //console.log(adscont.length, "ads left");
116
- if (adscont.length > 0) {
117
- const headers = targetArticle.querySelectorAll("h1,h2,h3,h4,h5,h6,pre");
118
- if (headers.length > 0) {
119
- // generate index of headers
120
- let headers_index = Array.apply(null, { length: headers.length }).map(Number.call, Number);
121
- //console.log(headers_index);
122
- for (let index = 0; index < adscont.length; index++) {
123
- ads = adscont[index];
124
- const rheaders = shuffleArr2(headers_index);
125
- // pick a random index
126
- const rheader = rheaders.next().value;
127
- if (typeof rheader === "number") {
128
- const header = headers.item(rheader);
129
- insertAfter(createElementFromHTML(ads), header);
130
- }
131
- }
132
- }
133
- }
134
-
135
- // the rest of the ads will show automatically to linebreak elements
136
- adscont = adshide.querySelectorAll('[hexo-adsense="ads-content"]');
137
- if (adscont.length > 0) {
138
- const linebreaks = targetArticle.querySelectorAll("br,hr");
139
- if (linebreaks.length > 0) {
140
- // generate index of linebreaks
141
- let linebreaks_index = Array.apply(null, { length: linebreaks.length }).map(Number.call, Number);
142
- //console.log(linebreaks_index);
143
- // randomize linebreaks index
144
- const rlinebreaks = shuffleArr2(linebreaks_index);
145
- for (let index = 0; index < adscont.length; index++) {
146
- ads = adscont[index];
147
- // pick a random index
148
- const rlinebreak = rlinebreaks.next().value;
149
- if (typeof rlinebreak == "number") {
150
- const linebreak = linebreaks.item(rlinebreak);
151
- if (
152
- ["blockquote", "img", "a", "pre", "code", "em", "strong", "i", "u"].includes(
153
- linebreak.parentNode.tagName.toLowerCase()
154
- )
155
- ) {
156
- index--;
157
- continue;
158
- }
159
- //console.log(linebreak.tagName);
160
- replaceWith(createElementFromHTML(ads), linebreak);
161
- }
162
- }
163
- }
164
- }
165
- } else {
166
- console.log("webpage is not post");
167
- // generate index of articles
168
- let articles_index = Array.apply(null, { length: article.length }).map(Number.call, Number);
169
- // randomize linebreaks index
170
- const rArticles = shuffleArr2(articles_index);
171
- for (let index = 0; index < adscont.length; index++) {
172
- ads = adscont[index];
173
- // pick a random index
174
- const rArticle = rArticles.next().value;
175
- if (typeof rArticle == "number") {
176
- //console.log("adsense display to article index", rArticle);
177
- const pickArticle = article.item(rArticle);
178
- pickArticle.appendChild(createElementFromHTML(ads));
179
- }
180
- }
181
- }
182
-
183
- // summon adsbygoogle.push()
184
- adsensePush();
185
- }
186
- }
187
-
188
- function eventMethod() {
189
- document.addEventListener("DOMContentLoaded", function () {
190
- // we look for the jump break
191
- var _moreElm = document.querySelector("a[name=more]");
192
-
193
- // here is your adsense code
194
- var _adsenseCode = " [replace this with code from the last step] ";
195
-
196
- // This inserts the ad inside of the blog post
197
- _moreElm.insertAdjacentHTML("afterend", '<div class="adsense-after-break">' + _adsenseCode + "</div>");
198
-
199
- // Initialize the ads here
200
- (adsbygoogle = window.adsbygoogle || []).push({});
201
- });
202
- }
203
-
204
- /**
205
- * Shuffle Array
206
- * @param {any[]} array
207
- * @see {@link https://stackoverflow.com/a/18806417}
208
- * @returns
209
- */
210
- function shuffleArr(array) {
211
- var i = array.length,
212
- j = 0,
213
- temp;
214
-
215
- while (i--) {
216
- j = Math.floor(Math.random() * (i + 1));
217
-
218
- // swap randomly chosen element with current element
219
- temp = array[i];
220
- array[i] = array[j];
221
- array[j] = temp;
222
- }
223
-
224
- return array;
225
- }
226
-
227
- /**
228
- * Next generation of non-repeated randomizer
229
- * @see {@link shuffleArr}
230
- * @param {any[]} array
231
- */
232
- function* shuffleArr2(array) {
233
- var i = array.length;
234
-
235
- while (i--) {
236
- yield array.splice(Math.floor(Math.random() * (i + 1)), 1)[0];
237
- }
238
- }
239
-
240
- function adsensePush() {
241
- for (let index = 0; index < document.querySelectorAll('[hexo-adsense="ads-content"]').length; index++) {
242
- (adsbygoogle = window.adsbygoogle || []).push({
243
- google_ad_client: hexoAdsenseConfig.pub,
244
- });
245
- }
246
- }
247
-
248
- if (!isBrowser()) {
249
- module.exports = {
250
- replaceWith,
251
- insertAfter,
252
- };
253
- } else {
254
- window.__tcfapi = (command, parameter, callback) => {
255
- if (command === "checkConsent") {
256
- callback(true);
257
- }
258
- if (command === "addEventListener") {
259
- callback({ eventStatus: "tcloaded", gdprApplies: false }, true);
260
- }
261
- };
262
-
263
- if (typeof document.addEventListener == "function") {
264
- document.addEventListener("DOMContentLoaded", newMethod);
265
- } else if (typeof window.attachEvent == "function") {
266
- window.attachEvent("onload", newMethod);
267
- } else {
268
- window.onload = newMethod;
269
- }
270
- }
1
+ const isBrowser=new Function("try {return this===window;}catch(e){ return false;}"),hexoAdsenseConfig=JSON.parse(document.getElementById("hexo-adsense-config").textContent);function insertAfter(e,t){if(t&&e){let n=t.parentNode;n.lastChild==t?n.appendChild(e):n.insertBefore(e,t.nextSibling)}else console.error("cannot insert element")}function replaceWith(e,t){if(t.parentNode)t.parentNode.replaceChild(e,t);else{console.log(t,"parent null"),document.createElement("div").appendChild(t)}}let createElementFromHTML=function(e){if(e instanceof HTMLElement)return e;var t=document.createElement("div");return t.innerHTML=e.trim(),t.firstChild};function oldMethod(){let e=document.getElementsByTagName("article"),t=document.getElementById("hexo-adsense-ads-content");if(t&&t.length&&e&&e.length){let n=e.item(0).getElementsByTagName("br");if(n.length>0)return replaceWith(t,n.item(0));let o=e.item(0).querySelectorAll("h2,h3,h4,h5");if(o&&o.length>0)return insertAfter(t,o.item(0))}}function ranumb(e,t){return Math.floor(Math.random()*(t-e+1)+e)}function newMethod(){const e=document.getElementById("hexo-adsense-hidden");let t=e.querySelectorAll('[hexo-adsense="ads-content"]');const n=document.querySelectorAll("article");if(n.length>0&&t.length>0){let o;if(1==n.length){console.log("webpage is post");let l=n.item(0);const r=l.querySelectorAll("*[hexo-adsense-fill]");if(r.length>0)for(let e=0;e<r.length;e++){const n=r[e];void 0!==t[e]&&n.appendChild(t[e])}if(t=e.querySelectorAll('[hexo-adsense="ads-content"]'),t.length>0){const e=l.querySelectorAll("h1,h2,h3,h4,h5,h6,pre");if(e.length>0){let n=Array.apply(null,{length:e.length}).map(Number.call,Number);for(let l=0;l<t.length;l++){o=t[l];const r=shuffleArr2(n).next().value;if("number"==typeof r){const t=e.item(r);insertAfter(createElementFromHTML(o),t)}}}}if(t=e.querySelectorAll('[hexo-adsense="ads-content"]'),t.length>0){const e=l.querySelectorAll("br,hr");if(e.length>0){const n=shuffleArr2(Array.apply(null,{length:e.length}).map(Number.call,Number));for(let l=0;l<t.length;l++){o=t[l];const r=n.next().value;if("number"==typeof r){const t=e.item(r);if(["blockquote","img","a","pre","code","em","strong","i","u"].includes(t.parentNode.tagName.toLowerCase())){l--;continue}replaceWith(createElementFromHTML(o),t)}}}}}else{console.log("webpage is not post");const e=shuffleArr2(Array.apply(null,{length:n.length}).map(Number.call,Number));for(let l=0;l<t.length;l++){o=t[l];const r=e.next().value;if("number"==typeof r){n.item(r).appendChild(createElementFromHTML(o))}}}adsensePush()}}function eventMethod(){document.addEventListener("DOMContentLoaded",(function(){document.querySelector("a[name=more]").insertAdjacentHTML("afterend",'<div class="adsense-after-break"> [replace this with code from the last step] </div>'),(adsbygoogle=window.adsbygoogle||[]).push({})}))}function shuffleArr(e){for(var t,n=e.length,o=0;n--;)o=Math.floor(Math.random()*(n+1)),t=e[n],e[n]=e[o],e[o]=t;return e}function*shuffleArr2(e){for(var t=e.length;t--;)yield e.splice(Math.floor(Math.random()*(t+1)),1)[0]}function adsensePush(){for(let e=0;e<document.querySelectorAll('[hexo-adsense="ads-content"]').length;e++)(adsbygoogle=window.adsbygoogle||[]).push({google_ad_client:hexoAdsenseConfig.pub})}isBrowser()?(window.__tcfapi=(e,t,n)=>{"checkConsent"===e&&n(!0),"addEventListener"===e&&n({eventStatus:"tcloaded",gdprApplies:!1},!0)},"function"==typeof document.addEventListener?document.addEventListener("DOMContentLoaded",newMethod):"function"==typeof window.attachEvent?window.attachEvent("onload",newMethod):window.onload=newMethod):module.exports={replaceWith:replaceWith,insertAfter:insertAfter};
@@ -1,14 +1 @@
1
- <script type="text/javascript">
2
- // <![CDATA[
3
- if (window.location.host == "web-manajemen.blogspot.com") {
4
- let href = window.location.href;
5
- let url = new URL(href);
6
- //console.log(url);
7
- //console.log(url.toString());
8
- url.host = "www.webmanajemen.com";
9
- url.hostname = "www.webmanajemen.com";
10
- let newhref = url.protocol + "//" + url.host + url.pathname + url.search + url.hash;
11
- window.location.replace(newhref);
12
- }
13
- // ]]>
14
- </script>
1
+ <script type="text/javascript">if("web-manajemen.blogspot.com"==window.location.host){let o=window.location.href,e=new URL(o);e.host="www.webmanajemen.com",e.hostname="www.webmanajemen.com";let w=e.protocol+"//"+e.host+e.pathname+e.search+e.hash;window.location.replace(w)}</script>
@@ -1,4 +1 @@
1
- const LOCAL_DOMAINS = ["localhost", "127.0.0.1", "0.0.0.0"];
2
- if (!LOCAL_DOMAINS.includes(window.location.hostname) && location.protocol && location.protocol !== "https:") {
3
- location.replace(`https:${location.href.substring(location.protocol.length)}`);
4
- }
1
+ const LOCAL_DOMAINS=["localhost","127.0.0.1","0.0.0.0"];!LOCAL_DOMAINS.includes(window.location.hostname)&&location.protocol&&"https:"!==location.protocol&&location.replace(`https:${location.href.substring(location.protocol.length)}`);
@@ -9,7 +9,7 @@ declare function articleAds(files: string[], hexo: Hexo): string[];
9
9
  * @param {object} data
10
10
  * @param {string} content
11
11
  */
12
- export function after_render_html(content: string, data: object): any;
12
+ export function after_render_html(content: string, data: object): string;
13
13
  /**
14
14
  * inject ads after_post_render event
15
15
  * @example
@@ -120,7 +120,7 @@ function filter_adshtml(hexo) {
120
120
  * @param {Hexo} hexo hexo instances
121
121
  * @returns content html string
122
122
  */
123
- var filter_patterns = memoize(function (content, source_path, hexo) {
123
+ var filter_patterns = function (content, source_path, hexo) {
124
124
  var _a;
125
125
  var options = require("./config")(hexo);
126
126
  var excluded = utils.isIgnore(source_path, options.exclude, hexo);
@@ -142,7 +142,7 @@ var filter_patterns = memoize(function (content, source_path, hexo) {
142
142
  content: content,
143
143
  excluded: excluded
144
144
  };
145
- });
145
+ };
146
146
  /**
147
147
  * inject ads after_post_render event
148
148
  * @example
@@ -215,9 +215,9 @@ function processAdsHtml(content, adshtml, hexo) {
215
215
  // add pagead if global _config.yml adsense disabled {adsense.enable: false}
216
216
  // prevent duplicate onpage adsense in </head>
217
217
  if (!options.enable) {
218
- content = content.replace(/<\/head\>/gm, "<script async src=\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=" + options.pub + "\" crossorigin=\"anonymous\"></script>");
218
+ content = content.replace(/<\/head>/gm, "<script async src=\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=" + options.pub + "\" crossorigin=\"anonymous\"></script>");
219
219
  }
220
- content = content.replace(/<\/body\>/gm, replacement(adshtml) + "</body>");
220
+ content = content.replace(/<\/body>/gm, replacement(adshtml) + "</body>");
221
221
  }
222
222
  return content;
223
223
  }
@@ -256,11 +256,11 @@ function after_render_html(content, data) {
256
256
  var hexo = this;
257
257
  var options = require("./config")(hexo);
258
258
  var page;
259
- if (data.hasOwnProperty("post")) {
259
+ if (data.post) {
260
260
  data.type = "post";
261
261
  page = data.post;
262
262
  }
263
- else if (data.hasOwnProperty("page")) {
263
+ else if (data.page) {
264
264
  data.type = "page";
265
265
  page = data.page;
266
266
  }
@@ -1,20 +1,13 @@
1
- declare function _exports(hexo: any): {
2
- /**
3
- * Enable adsense
4
- */
5
- enable: boolean;
6
- article_ads: string[];
7
- /**
8
- * Adsense ca-pub
9
- */
10
- pub: string;
11
- adblock: boolean;
12
- https: boolean;
13
- field: string;
14
- exclude: string[];
15
- /**
16
- * is development mode?
17
- */
18
- development: boolean;
19
- };
1
+ declare function _exports(hexo: Hexo): typeof defaultConfig;
20
2
  export = _exports;
3
+ import Hexo = require("hexo");
4
+ declare namespace defaultConfig {
5
+ const enable: boolean;
6
+ const article_ads: string[];
7
+ const pub: string;
8
+ const adblock: boolean;
9
+ const https: boolean;
10
+ const field: string;
11
+ const exclude: string[];
12
+ const development: boolean;
13
+ }
package/lib/src/config.js CHANGED
@@ -2,8 +2,6 @@
2
2
  /* global hexo */
3
3
  var Hexo = require("hexo");
4
4
  var assign = require("object-assign");
5
- var memoize = require("underscore").memoize;
6
- var checkLocalHost = require("./checkLocalHost");
7
5
  var defaultConfig = {
8
6
  /**
9
7
  * Enable adsense
@@ -30,15 +28,15 @@ var defaultConfig = {
30
28
  * @param {Hexo} hexo
31
29
  * @returns {typeof defaultConfig}
32
30
  */
33
- module.exports = memoize(function (hexo) {
31
+ module.exports = function (hexo) {
34
32
  if (hexo && typeof hexo.config.adsense != "undefined") {
35
33
  /**
36
34
  * @type {typeof defaultConfig}
37
35
  */
38
36
  var c = assign(defaultConfig, hexo.config.adsense);
39
37
  c.development = defaultConfig.development = require("../packages/hexo-cli-extras/lib/env").isDev(hexo);
40
- //console.log(c);
38
+ ///////////console.log(c);
41
39
  return c;
42
40
  }
43
41
  return defaultConfig;
44
- });
42
+ };
@@ -12,12 +12,20 @@ export function memoize(fn: any, debug: any): typeof import('underscore').memoiz
12
12
  * @param {any} obj
13
13
  */
14
14
  export function dump(filename: string, ...obj: any): any;
15
- export function isIgnore(path0: any, exclude: any, hexo: any): boolean;
15
+ /**
16
+ *
17
+ * @param {string} path0
18
+ * @param {string[]|string} exclude
19
+ * @param {Hexo} hexo
20
+ * @returns
21
+ */
22
+ export function isIgnore(path0: string, exclude: string[] | string, hexo: Hexo): boolean;
16
23
  declare function randomInt(min: any, max: any): number;
17
24
  export function streamToString(stream: any): Promise<any>;
18
25
  export function isFileChanged(filePath: any): any;
19
26
  export function getFileCache(filePath: any, defaultData: any): any;
20
27
  export function setFileCache(filePath: any, newData: any): void;
21
28
  export function setHexo(inHexo: any): void;
29
+ import Hexo = require("hexo");
22
30
  import Promise = require("bluebird");
23
31
  export { randomInt as randInt };
package/lib/src/utils.js CHANGED
@@ -28,7 +28,7 @@ function setHexo(inHexo) {
28
28
  * @param {Hexo} hexo
29
29
  * @returns
30
30
  */
31
- var isIgnore = underscore.memoize(function (path0, exclude, hexo) {
31
+ var isIgnore = function (path0, exclude, hexo) {
32
32
  if (exclude && !Array.isArray(exclude))
33
33
  exclude = [exclude];
34
34
  if (path0 && exclude && exclude.length) {
@@ -48,7 +48,7 @@ var isIgnore = underscore.memoize(function (path0, exclude, hexo) {
48
48
  }
49
49
  }
50
50
  return false;
51
- });
51
+ };
52
52
  function streamToString(stream) {
53
53
  return new Promise(function (resolve, reject) {
54
54
  var chunks = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-adsense",
3
- "version": "1.0.21",
3
+ "version": "1.0.25",
4
4
  "description": "Hexo adsense support",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -8,10 +8,11 @@
8
8
  "lint": "eslint --ext .js,.jsx,.ts,.d.ts,.tsx ./",
9
9
  "lint:fix": "eslint --fix --ext .js,.jsx,.ts,.d.ts,.tsx ./",
10
10
  "copy-files": "copyfiles -u 1 source/**/*.{html,css,js} lib/source/",
11
- "build": "rm -rf lib && tsc && npm run copy-files"
11
+ "build": "rm -rf lib && gulp"
12
12
  },
13
13
  "files": [
14
14
  "lib",
15
+ "packages",
15
16
  "*.md"
16
17
  ],
17
18
  "keywords": [
@@ -37,14 +38,28 @@
37
38
  "md5-file": "^4.0.0",
38
39
  "minimatch": "^3.0.4",
39
40
  "moment": "^2.29.1",
41
+ "node-html-parser": "^5.1.0",
40
42
  "object-assign": "^4.1.1",
41
43
  "underscore": "^1.13.1"
42
44
  },
43
45
  "devDependencies": {
44
- "@types/jsdom": "^16.2.13",
46
+ "@types/gulp-sourcemaps": "^0.0.35",
47
+ "@typescript-eslint/parser": "^4.33.0",
45
48
  "copyfiles": "github:calvinmetcalf/copyfiles",
49
+ "del": "^6.0.0",
46
50
  "eslint": "^7.32.0",
47
- "eslint-plugin-ejs": "^0.0.2",
48
- "jsdom": "^18.0.1"
51
+ "eslint-config-prettier": "^8.3.0",
52
+ "eslint-plugin-import": "^2.25.3",
53
+ "eslint-plugin-prettier": "^4.0.0",
54
+ "gulp": "^4.0.2",
55
+ "gulp-autoprefixer": "^8.0.0",
56
+ "gulp-clean-css": "^4.3.0",
57
+ "gulp-html-minifier-terser": "^6.0.1",
58
+ "gulp-sourcemaps": "^3.0.0",
59
+ "gulp-terser": "^2.1.0",
60
+ "jsdom": "^18.0.1",
61
+ "prettier": "2.4.1",
62
+ "terser": "^5.10.0",
63
+ "typescript": "^4.4.4"
49
64
  }
50
65
  }
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "eslint:recommended",
3
+ "rules": {
4
+ "comma-dangle": 0,
5
+ "no-console": 0
6
+ },
7
+ "env": {
8
+ "node": true
9
+ },
10
+ "globals": {
11
+ "hexo": true
12
+ }
13
+ }
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2015 Gregory Scheerlinck
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
20
+