sfc-utils 1.4.183 → 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.
@@ -41,15 +41,7 @@ function appendLayoutScripts(
41
41
  j.src = "https://www.googletagmanager.com/gtm.js?id=" + i + dl;
42
42
  f.parentNode.insertBefore(j, f);
43
43
  })(window, document, "script", "dataLayer", "GTM-P38VLD8M");
44
- // Add new md5 script
45
- let script = document.createElement("script");
46
- script.type = "text/javascript";
47
- script.src = "https://projects.sfchronicle.com/shared/js/md5.js";
48
- document.body.appendChild(script);
49
- let script2 = document.createElement("script");
50
- script2.type = "text/javascript";
51
- script2.src = "https://nexus.ensighten.com/hearst/news/Bootstrap.js";
52
- document.body.appendChild(script2);
44
+ // NO MORE ENSIGHTEN OR MD5!
53
45
  } else {
54
46
  let script = document.createElement("script");
55
47
  script.type = "text/javascript";
@@ -80,8 +72,9 @@ function appendLayoutScripts(
80
72
  link.rel = "stylesheet";
81
73
  link.href = `https://htlbid.com/v3/${shortDomain}/hnpbid.css`;
82
74
  document.head.appendChild(link);
83
- setTimeout(() => {
84
- // 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
85
78
  if (window.hnpbid) {
86
79
  console.log("hnpbid exists");
87
80
  window.hnpbid = window.hnpbid || {};
@@ -110,24 +103,13 @@ function appendLayoutScripts(
110
103
  // init
111
104
  window.hnpbid.layout();
112
105
  });
106
+ } else if (attempt < maxAttempts) {
107
+ setTimeout(() => pollForHnpbid(attempt + 1, maxAttempts), 200);
113
108
  } else {
114
- console.log("hnpbid does not exist");
115
- // If global var was not defined, start Juice
116
- let script = document.createElement("script");
117
- script.type = "text/javascript";
118
- script.id = "adPositionManagerScriptTag";
119
- script.src = "https://aps.hearstnp.com/Scripts/loadAds.js";
120
- document.body.appendChild(script);
109
+ console.log("hnpbid does not exist! ads disabled");
121
110
  }
122
- }, 1000);
123
- } else {
124
- console.log("juice fallback");
125
- // If no category, this is the old version and we're supporting Juice (expires in Nov 2024)
126
- let script = document.createElement("script");
127
- script.type = "text/javascript";
128
- script.id = "adPositionManagerScriptTag";
129
- script.src = "https://aps.hearstnp.com/Scripts/loadAds.js";
130
- document.body.appendChild(script);
111
+ };
112
+ pollForHnpbid();
131
113
  }
132
114
  }
133
115
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sfc-utils",
3
- "version": "1.4.183",
3
+ "version": "1.4.185",
4
4
  "author": "ewagstaff <evanjwagstaff@gmail.com>",
5
5
  "dependencies": {
6
6
  "archieml": "^0.4.2",