sfc-utils 1.4.184 → 1.4.185

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.
@@ -72,8 +72,9 @@ function appendLayoutScripts(
72
72
  link.rel = "stylesheet";
73
73
  link.href = `https://htlbid.com/v3/${shortDomain}/hnpbid.css`;
74
74
  document.head.appendChild(link);
75
- setTimeout(() => {
76
- // Add vars after timeout
75
+ // Poll for hnpbid every 200ms for up to 10 seconds
76
+ const pollForHnpbid = (attempt = 0, maxAttempts = 50) => {
77
+ // 50 attempts * 200ms = 10 seconds
77
78
  if (window.hnpbid) {
78
79
  console.log("hnpbid exists");
79
80
  window.hnpbid = window.hnpbid || {};
@@ -102,24 +103,13 @@ function appendLayoutScripts(
102
103
  // init
103
104
  window.hnpbid.layout();
104
105
  });
106
+ } else if (attempt < maxAttempts) {
107
+ setTimeout(() => pollForHnpbid(attempt + 1, maxAttempts), 200);
105
108
  } else {
106
- console.log("hnpbid does not exist");
107
- // If global var was not defined, start Juice
108
- let script = document.createElement("script");
109
- script.type = "text/javascript";
110
- script.id = "adPositionManagerScriptTag";
111
- script.src = "https://aps.hearstnp.com/Scripts/loadAds.js";
112
- document.body.appendChild(script);
109
+ console.log("hnpbid does not exist! ads disabled");
113
110
  }
114
- }, 1000);
115
- } else {
116
- console.log("juice fallback");
117
- // If no category, this is the old version and we're supporting Juice (expires in Nov 2024)
118
- let script = document.createElement("script");
119
- script.type = "text/javascript";
120
- script.id = "adPositionManagerScriptTag";
121
- script.src = "https://aps.hearstnp.com/Scripts/loadAds.js";
122
- document.body.appendChild(script);
111
+ };
112
+ pollForHnpbid();
123
113
  }
124
114
  }
125
115
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sfc-utils",
3
- "version": "1.4.184",
3
+ "version": "1.4.185",
4
4
  "author": "ewagstaff <evanjwagstaff@gmail.com>",
5
5
  "dependencies": {
6
6
  "archieml": "^0.4.2",