nodebb-plugin-pdf-secure2 1.3.3 → 1.3.4
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.
- package/library.js +1 -18
- package/package.json +1 -1
- package/static/lib/main.js +0 -9
package/library.js
CHANGED
|
@@ -10,7 +10,6 @@ const controllers = require('./lib/controllers');
|
|
|
10
10
|
const nonceStore = require('./lib/nonce-store');
|
|
11
11
|
const pdfHandler = require('./lib/pdf-handler');
|
|
12
12
|
const geminiChat = require('./lib/gemini-chat');
|
|
13
|
-
const topics = require.main.require('./src/topics');
|
|
14
13
|
|
|
15
14
|
const plugin = {};
|
|
16
15
|
|
|
@@ -230,11 +229,8 @@ plugin.filterMetaTags = async (hookData) => {
|
|
|
230
229
|
return hookData;
|
|
231
230
|
};
|
|
232
231
|
|
|
233
|
-
// Inject
|
|
232
|
+
// Inject plugin config into client-side
|
|
234
233
|
plugin.filterConfig = async function (data) {
|
|
235
|
-
if (data && data.config) {
|
|
236
|
-
data.config.pdfSecureCategories = pluginSettings.allowedCategories || '';
|
|
237
|
-
}
|
|
238
234
|
return data;
|
|
239
235
|
};
|
|
240
236
|
|
|
@@ -245,19 +241,6 @@ plugin.transformPdfLinks = async (data) => {
|
|
|
245
241
|
return data;
|
|
246
242
|
}
|
|
247
243
|
|
|
248
|
-
// Category check — only transform in allowed categories
|
|
249
|
-
const allowedStr = pluginSettings.allowedCategories || '';
|
|
250
|
-
const allowed = allowedStr.split(',').map(s => s.trim()).filter(Boolean);
|
|
251
|
-
if (allowed.length > 0 && data.postData.tid) {
|
|
252
|
-
let cid = data.postData.cid;
|
|
253
|
-
if (!cid) {
|
|
254
|
-
cid = await topics.getTopicField(data.postData.tid, 'cid');
|
|
255
|
-
}
|
|
256
|
-
if (cid && !allowed.includes(String(cid))) {
|
|
257
|
-
return data;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
244
|
// Regex to match PDF links: <a href="...xxx.pdf">text</a>
|
|
262
245
|
// Captures: full URL path, filename, link text
|
|
263
246
|
const pdfLinkRegex = /<a\s+[^>]*href=["']([^"']*\/([^"'\/]+\.pdf))["'][^>]*>([^<]*)<\/a>/gi;
|
package/package.json
CHANGED
package/static/lib/main.js
CHANGED
|
@@ -283,15 +283,6 @@
|
|
|
283
283
|
}
|
|
284
284
|
|
|
285
285
|
function interceptPdfLinks() {
|
|
286
|
-
// Category check — only intercept in allowed categories
|
|
287
|
-
var allowedCats = (config.pdfSecureCategories || '').split(',').filter(Boolean);
|
|
288
|
-
if (allowedCats.length > 0) {
|
|
289
|
-
var currentCid = ajaxify && ajaxify.data && String(ajaxify.data.cid || '');
|
|
290
|
-
if (currentCid && !allowedCats.includes(currentCid)) {
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
|
|
295
286
|
var postContents = document.querySelectorAll('[component="post/content"]');
|
|
296
287
|
|
|
297
288
|
postContents.forEach(function (content) {
|