nodebb-plugin-pdf-secure 1.2.21 → 1.2.22

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 (2) hide show
  1. package/package.json +1 -1
  2. package/static/viewer.html +17 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-pdf-secure",
3
- "version": "1.2.21",
3
+ "version": "1.2.22",
4
4
  "description": "Secure PDF viewer plugin for NodeBB - prevents downloading, enables canvas-only rendering with Premium group support",
5
5
  "main": "library.js",
6
6
  "repository": {
@@ -1582,7 +1582,7 @@
1582
1582
  align-items: center;
1583
1583
  justify-content: center;
1584
1584
  background: linear-gradient(180deg, rgba(31,31,31,0.95) 0%, rgba(20,20,20,0.98) 100%);
1585
- z-index: 5;
1585
+ z-index: 15;
1586
1586
  text-align: center;
1587
1587
  padding: 20px;
1588
1588
  }
@@ -2249,8 +2249,16 @@
2249
2249
  pageEl.appendChild(overlay);
2250
2250
  }
2251
2251
 
2252
+ function isOverlayTampered(overlay) {
2253
+ var s = overlay.style;
2254
+ return s.position !== 'absolute' || s.display !== 'flex' ||
2255
+ s.zIndex !== '15' || s.opacity !== '1' ||
2256
+ s.visibility !== 'visible' || s.pointerEvents !== 'auto';
2257
+ }
2258
+
2252
2259
  function resetOverlayCSS(overlay) {
2253
- overlay.style.cssText = 'position:absolute;top:0;left:0;right:0;bottom:0;display:flex;z-index:5;opacity:1;visibility:visible;pointer-events:auto;';
2260
+ if (!isOverlayTampered(overlay)) return; // Skip if already correct (prevents observer loop)
2261
+ overlay.style.cssText = 'position:absolute;top:0;left:0;right:0;bottom:0;display:flex;z-index:15;opacity:1;visibility:visible;pointer-events:auto;';
2254
2262
  }
2255
2263
 
2256
2264
  function applyPageLocks() {
@@ -2313,9 +2321,11 @@
2313
2321
  for (var i = 0; i < mutations.length; i++) {
2314
2322
  var target = mutations[i].target;
2315
2323
  if (!target || !target.classList) continue;
2316
- // Overlay CSS tampered - reset it
2324
+ // Overlay CSS tampered - reset only if values actually differ
2317
2325
  if (target.classList.contains('page-lock-overlay')) {
2318
- resetOverlayCSS(target);
2326
+ if (isOverlayTampered(target)) {
2327
+ resetOverlayCSS(target);
2328
+ }
2319
2329
  }
2320
2330
  // Blur class removed from locked page - re-add it
2321
2331
  if (target.classList.contains('page') && !target.classList.contains('page-locked-blur')) {
@@ -2907,6 +2917,9 @@
2907
2917
 
2908
2918
  // Annotation Layer with Persistence
2909
2919
  async function injectAnnotationLayer(pageNum) {
2920
+ // Skip annotation injection on locked pages
2921
+ if (premiumInfo && !premiumInfo.isPremium && pageNum > 1) return;
2922
+
2910
2923
  const pageView = pdfViewer.getPageView(pageNum - 1);
2911
2924
  if (!pageView?.div) return;
2912
2925