PageSourceSearch

https://www.gofugyourself.com/wp-content/plugins/htlbid-layout/assets/inject-ads.js?ver=35f32445b924996a

js gofugyourself.com collected 2026-10-02 06:33:25 UTC 6,873 bytes, 200 lines download raw bytes

1((win, doc) => {
2
3  const makeAdDiv = ( className = '' ) => {
4    const adDiv = doc.createElement('div');
5    if( className ) {
6      adDiv.classList.add( className );
7    }
8    return adDiv;
9  }
10
11  const getParent = ( el ) => {
12    return el.parentNode;
13  }
14
15  const featuredInsertOnMobile = (elements) => {
16      console.log( 'featuredInsertOnMobile' );
17      console.log( elements );
18      if (elements.length >= 8) {
19          // insert ads every 3 <p>'s, starting after the 2nd <p>.
20          elements.forEach((value, index) => {
21              console.log( value );
22              console.log( index );
23              
24              if ((index + 1) % 3 === 2) {
25                  if (index > 0 && index < 3) {
26                      getParent( value ).insertBefore( makeAdDiv( 'htlad-Mobile_InLine_MedRec_1' ), value ); // only the first.
27                  } else {
28                      getParent( value ).insertBefore( makeAdDiv( 'htlad-Mobile_InLine_MedRec_2' ), value );
29                  }
30              }
31          });
32      } else if (elements.length < 8) {
33          elements.forEach((value, index) => {
34              console.log( value );
35              console.log( index );
36              
37              if (index === 0) {
38                  value.classList.add('htl_prepend_inline_medrec');// first
39              } else if ((index + 1) % 3 === 0) {
40                  getParent( value ).insertBefore( makeAdDiv( 'htlad-Mobile_InLine_MedRec_2' ), value );
41              }
42          });
43      }
44  };
45
46  const featuredInsertOnDesktop = (elements) => {
47      elements.forEach((value, index) => {
48          if (index === 1) {
49              getParent( value ).insertBefore( makeAdDiv( 'htlad-Mobile_InLine_MedRec_1' ), value );
50          } else if ((index > 5) && ((index - 1) % 6 === 0)) {
51              getParent( value ).insertBefore( makeAdDiv( 'htlad-Mobile_InLine_MedRec_2' ), value );
52          }
53      });
54  };
55
56  const articleInsertOnDesktop = (elements) => {
57      console.log('articleInsertOnDesktop');
58      console.log( elements.length )
59      if (elements.length > 0) {
60          elements[elements.length - 1].classList.add('htl_inline_medrec_2');
61      }
62  };
63
64  const articleInsertOnMobile = (elements) => {
65      if (elements.length <= 3) {
66          elements.forEach((value, index) => {
67              if (index === 0) {
68                  getParent( value ).insertBefore( makeAdDiv( 'htlad-Mobile_InLine_MedRec_1_2' ), value ); // only the first.
69              } else if (index === elements.length - 1) {
70                  getParent( value ).insertBefore( makeAdDiv( 'htlad-Mobile_InLine_MedRec_2' ), value );
71              }
72          });
73      } else if (elements.length < 8) {
74          elements.forEach((value, index) => {
75              if (index === 0) {
76                  getParent( value ).insertBefore( makeAdDiv( 'htlad-Mobile_InLine_MedRec_1' ), value );// first
77              } else if (index === elements.length - 1) {
78                  getParent( value ).insertBefore( makeAdDiv( 'htlad-Mobile_InLine_MedRec_2' ), value );
79              }
80          });
81      } else if (elements.length >= 8) {
82          elements.forEach((value, index) => {
83              if (index === 1) {
84                  getParent( value ).insertBefore( makeAdDiv( 'htlad-Mobile_InLine_MedRec_1' ), value );              
85              } else if (index === 4) {
86                  getParent( value ).insertBefore( makeAdDiv( 'htlad-Mobile_InLine_MedRec_2' ), value ); 
87              } else if (index === elements.length - 1) {
88                  getParent( value ).insertBefore( makeAdDiv( 'htlad-Mobile_InLine_MedRec_3' ), value ); 
89              }
90          });
91      }
92  };
93
94  const setupFeaturedPage = () => {
95      console.log('setupFeaturedPage');
96      const selector = 'div#featured-content section.content-text p';
97      const elements = doc.querySelectorAll(selector);
98
99      if (win.isMobile) {
100          featuredInsertOnMobile(elements);
101      } else {
102          featuredInsertOnDesktop(elements);
103      }
104  };
105
106  const setupArticlePage = () => {
107      console.log('setupArticlePage')
108      const selector = "div[itemprop='articleBody'] p"; // for desktop articles.
109      const elements = doc.querySelectorAll(selector);
110
111      if (win.isMobile) {
112          articleInsertOnMobile(elements);
113      } else {
114          articleInsertOnDesktop(elements);
115      }
116  };
117
118  const setupMobileContentLayout = () => {
119      console.log('setupMobileContentLayout');
120      
121      const selector = 'div.content_holder > div.clear';
122      const elements = doc.querySelectorAll(selector);
123
124      elements.forEach((value, index) => {
125          if ((index + 1) % 3 === 0) {
126              if (index > 0 && index < 3) {
127                  getParent( value ).insertBefore( makeAdDiv( 'htlad-Mobile_InLine_MedRec_1' ), value );// only index 2.
128              } else {
129                  getParent( value ).insertBefore( makeAdDiv( 'htlad-Mobile_InLine_MedRec_2' ), value );
130              }
131          }
132      });
133  };
134
135  const isDesktopFeature = () => {
136    return doc.body.classList.contains('featured-template-default');
137  }
138
139  const isMobileFeature = () => {
140      return doc.body.classList.contains('featured-template-default') &&
141      doc.body.classList.contains('mobile');
142  }
143
144  const isMobile = ()=> {
145    return doc.body.classList.contains('mobile');
146  }
147
148  function doDocumentLoaded() {
149      console.log('doDocumentLoaded');
150      // win.mobileDetect is set by GFY
151      win.isMobile = win.mobileDetect.isMobile === '1';
152
153      const isFeatured = isDesktopFeature() || isMobileFeature();
154      const isMobileContentLayout = isMobile();
155
156      if (isFeatured) {
157          console.log('isFeatured')
158          setupFeaturedPage();
159      }
160
161      if (isMobileContentLayout) {
162          console.log('isMobileContentLayout')
163          setupMobileContentLayout();
164      }
165
166      setupArticlePage();
167
168      // actually do the refresh, if the flag is set
169      const doRefresh = () => {
170          if (!win.mayRefreshGalleryAd) {
171              return;
172          }
173          win.mayRefreshGalleryAd = false;
174          htlbid.cmd.push(() => {
175              htlbid.forceRefresh();
176          });
177      };
178      win.refreshGalleryAds = doRefresh;
179  }
180
181  // global variable that determines whether clicking a slideshow button
182  // should also refresh the slideshow ads
183  win.mayRefreshGalleryAd = false;
184
185  win.googletag = win.googletag || {};
186  win.googletag.cmd = win.googletag.cmd || [];
187  win.googletag.cmd.push(() => {
188      win.googletag.pubads().addEventListener('impressionViewable', () => {
189          // allow refreshing gallery ads on the next click
190          win.mayRefreshGalleryAd = true;
191      });
192  });
193
194  if (doc.readyState !== 'loading') {
195      doDocumentLoaded();
196  } else {
197      doc.addEventListener('DOMContentLoaded', doDocumentLoaded);
198  }
199
200})( window, document );

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.