sfc-utils 1.4.146 → 1.4.148

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.
@@ -18,7 +18,6 @@ function debounce(fn, ms) {
18
18
 
19
19
  function appendLayoutScripts(isEmbedded, isAdRemoved, marketKey, category) {
20
20
  const isApp = appCheck();
21
- console.log("utils current env", currentEnv);
22
21
 
23
22
  // React Helmet is actually terrible and runs these scripts twice, so we are including them async ourselves
24
23
  // Run analytics and resizing scripts right away so we take care of that
@@ -53,6 +52,7 @@ function appendLayoutScripts(isEmbedded, isAdRemoved, marketKey, category) {
53
52
  const fullURL = window.location.href;
54
53
  const shortDomain = domain.replace("https://www.", "");
55
54
  const script = document.createElement("script");
55
+ // Try to get the htlbid URL to see if it's enabled
56
56
  script.type = "text/javascript";
57
57
  script.src = `https://htlbid.com/v3/${shortDomain}/hnpbid.js`;
58
58
  document.body.appendChild(script);
@@ -61,21 +61,35 @@ function appendLayoutScripts(isEmbedded, isAdRemoved, marketKey, category) {
61
61
  link.rel = "stylesheet";
62
62
  link.href = `https://htlbid.com/v3/${shortDomain}/hnpbid.css`;
63
63
  document.head.appendChild(link);
64
- // Add vars
65
- window.hnpbid = window.hnpbid || {};
66
- window.hnpbid.cmd = window.hnpbid.cmd || [];
67
- window.hnpbid.cmd.push(() => {
68
- window.hnpbid.setTargeting(
69
- "is_testing",
70
- currentEnv === "production" ? "no" : "yes"
71
- ); // Set to "no" for production
72
- window.hnpbid.setTargeting("is_home", "no"); // Set to "yes" on the homepage
73
- window.hnpbid.setTargeting("post_id", `${fullURL}`);
74
- window.hnpbid.setTargeting("category", category || "news");
75
- // init
76
- window.hnpbid.layout();
77
- });
64
+ setTimeout(() => {
65
+ // Add vars after timeout
66
+ if (window.hnpbid) {
67
+ console.log("hnpbid exists");
68
+ window.hnpbid = window.hnpbid || {};
69
+ window.hnpbid.cmd = window.hnpbid.cmd || [];
70
+ window.hnpbid.cmd.push(() => {
71
+ window.hnpbid.setTargeting(
72
+ "is_testing",
73
+ currentEnv === "production" ? "no" : "yes"
74
+ ); // Set to "no" for production
75
+ window.hnpbid.setTargeting("is_home", "no"); // Set to "yes" on the homepage
76
+ window.hnpbid.setTargeting("post_id", `${fullURL}`);
77
+ window.hnpbid.setTargeting("category", category || "news");
78
+ // init
79
+ window.hnpbid.layout();
80
+ });
81
+ } else {
82
+ console.log("hnpbid does not exist");
83
+ // If global var was not defined, start Juice
84
+ let script = document.createElement("script");
85
+ script.type = "text/javascript";
86
+ script.id = "adPositionManagerScriptTag";
87
+ script.src = "https://aps.hearstnp.com/Scripts/loadAds.js";
88
+ document.body.appendChild(script);
89
+ }
90
+ }, 1000);
78
91
  } else {
92
+ console.log("juice fallback");
79
93
  // If no category, this is the old version and we're supporting Juice (expires in Nov 2024)
80
94
  let script = document.createElement("script");
81
95
  script.type = "text/javascript";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sfc-utils",
3
- "version": "1.4.146",
3
+ "version": "1.4.148",
4
4
  "author": "ewagstaff <evanjwagstaff@gmail.com>",
5
5
  "dependencies": {
6
6
  "archieml": "^0.4.2",