peertube-plugin-vast-loop-ads 1.0.2 → 1.0.3

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.

Potentially problematic release.


This version of peertube-plugin-vast-loop-ads might be problematic. Click here for more details.

@@ -2813,9 +2813,12 @@ var settings = (s) => {
2813
2813
  };
2814
2814
  };
2815
2815
  var loadContribAds = async (player) => {
2816
+ if (typeof player.ads === "function")
2817
+ return;
2816
2818
  try {
2817
2819
  await Promise.resolve().then(() => __toESM(require_videojs_ads_min()));
2818
2820
  await Promise.resolve().then(() => __toESM(require_videojsx_vast()));
2821
+ await new Promise((resolve) => setTimeout(resolve, 100));
2819
2822
  if (typeof player.ads === "function") {
2820
2823
  player.ads({
2821
2824
  debug: false,
@@ -2823,12 +2826,12 @@ var loadContribAds = async (player) => {
2823
2826
  playAdAlways: true,
2824
2827
  timeout: 5e3
2825
2828
  });
2826
- console.log("VAST Plugin: Ads infrastructure ready.");
2829
+ console.log("VAST Plugin: Ads infrastructure initialized successfully.");
2827
2830
  } else {
2828
- console.error("VAST Plugin: player.ads is still not defined after import");
2831
+ console.error("VAST Plugin: Script loaded but player.ads is missing. Check your Browser Tracking Prevention/AdBlocker!");
2829
2832
  }
2830
2833
  } catch (e) {
2831
- console.error("VAST Plugin: Error loading ads scripts", e);
2834
+ console.error('VAST Plugin: Critical error loading scripts. The browser might be blocking files with "ads" in filename.', e);
2832
2835
  }
2833
2836
  };
2834
2837
  var getRollsStatus = (pluginSettings2) => {
@@ -2813,9 +2813,12 @@ var settings = (s) => {
2813
2813
  };
2814
2814
  };
2815
2815
  var loadContribAds = async (player) => {
2816
+ if (typeof player.ads === "function")
2817
+ return;
2816
2818
  try {
2817
2819
  await Promise.resolve().then(() => __toESM(require_videojs_ads_min()));
2818
2820
  await Promise.resolve().then(() => __toESM(require_videojsx_vast()));
2821
+ await new Promise((resolve) => setTimeout(resolve, 100));
2819
2822
  if (typeof player.ads === "function") {
2820
2823
  player.ads({
2821
2824
  debug: false,
@@ -2823,12 +2826,12 @@ var loadContribAds = async (player) => {
2823
2826
  playAdAlways: true,
2824
2827
  timeout: 5e3
2825
2828
  });
2826
- console.log("VAST Plugin: Ads infrastructure ready.");
2829
+ console.log("VAST Plugin: Ads infrastructure initialized successfully.");
2827
2830
  } else {
2828
- console.error("VAST Plugin: player.ads is still not defined after import");
2831
+ console.error("VAST Plugin: Script loaded but player.ads is missing. Check your Browser Tracking Prevention/AdBlocker!");
2829
2832
  }
2830
2833
  } catch (e) {
2831
- console.error("VAST Plugin: Error loading ads scripts", e);
2834
+ console.error('VAST Plugin: Critical error loading scripts. The browser might be blocking files with "ads" in filename.', e);
2832
2835
  }
2833
2836
  };
2834
2837
  var getRollsStatus = (pluginSettings) => {
package/lib/shared.js CHANGED
@@ -25,25 +25,31 @@ export const settings = (s) => ({
25
25
  });
26
26
 
27
27
  export const loadContribAds = async (player) => {
28
+ // ถ้ามีอยู่แล้วไม่ต้องโหลดซ้ำ
29
+ if (typeof player.ads === 'function') return;
30
+
28
31
  try {
29
- // 1. ต้องโหลดทั้ง 2 ตัวนี้เสมอครับ ห้ามขาดตัวใดตัวหนึ่ง
32
+ // โหลดสคริปต์
30
33
  await import('../public/scripts/videojs.ads.min.js');
31
34
  await import('../public/scripts/videojsx.vast.js');
32
35
 
33
- // 2. ใช้ if เช็คเพื่อความชัวร์ จะได้ไม่เกิดอาการ "player.ads is not a function"
36
+ // ทิ้งจังหวะให้เบราว์เซอร์ประมวลผลสคริปต์นิดนึง (ป้องกัน race condition)
37
+ await new Promise(resolve => setTimeout(resolve, 100));
38
+
34
39
  if (typeof player.ads === 'function') {
35
40
  player.ads({
36
41
  debug: false,
37
- allowVjsAutoplay: true, // อนุญาตให้เล่นอัตโนมัติ
38
- playAdAlways: true, // พยายามข้ามข้อจำกัดบางอย่างเพื่อให้โฆษณาเล่นได้บ่อยขึ้น
39
- timeout: 5000 // ถ้าโหลดโฆษณาช้าเกิน 5 วินาที ให้ข้ามไปเล่นวิดีโอหลักเลย (คนฟังจะได้ไม่รอเก้อ)
42
+ allowVjsAutoplay: true,
43
+ playAdAlways: true,
44
+ timeout: 5000
40
45
  });
41
- console.log("VAST Plugin: Ads infrastructure ready.");
46
+ console.log("VAST Plugin: Ads infrastructure initialized successfully.");
42
47
  } else {
43
- console.error('VAST Plugin: player.ads is still not defined after import');
48
+ // ถ้ายังไม่ได้อีก แสดงว่าไฟล์โดนเบราว์เซอร์บล็อกทิ้ง (404 หรือ Blocked)
49
+ console.error('VAST Plugin: Script loaded but player.ads is missing. Check your Browser Tracking Prevention/AdBlocker!');
44
50
  }
45
51
  } catch (e) {
46
- console.error('VAST Plugin: Error loading ads scripts', e);
52
+ console.error('VAST Plugin: Critical error loading scripts. The browser might be blocking files with "ads" in filename.', e);
47
53
  }
48
54
  };
49
55
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "peertube-plugin-vast-loop-ads",
3
3
  "description": "Display vast ads in peertube",
4
- "version": "1.0.2",
4
+ "version": "1.0.3",
5
5
  "license": "BSD-3-Clause",
6
6
  "author": "Ignacio Aguirre",
7
7
  "bugs": "",