PageSourceSearch

https://ar15discounts.com/wp-content/plugins/dbi-application/assets/js/vikingAssuranceCard.js?ver=003

js ar15discounts.com collected 2026-09-25 23:41:13 UTC 8,443 bytes, 292 lines download raw bytes

1(() => {
2  const CONTAINER_ID = 'viking-widget-container';
3  const WIDGET_SELECTOR = '.ac-widget';
4  const EXTERNAL_SRC =
5    'https://produs-ccs-assurancecard-service.sgsonline.net/assurancecard/be8e7fbc4499573f7b145a56278b3cf85bf003488c6d5bb2f611290b316e4afdedc8452f8c3d14d5/cardJs';
6  const WIDGET_SELECTOR_INLINE = '.ac-widget';
7  const EXTERNAL_SRC_INLINE = 'https://produs-ccs-assurancecard-service.sgsonline.net/assurancecard/be8e7fbc4499573f7b145a56278b3cf85bf003488c6d5bb2f611290b316e4afdedc8452f8c3d14d5/cardJs';
8
9  if (window.top !== window.self) {
10    try {
11      const isAssuranceSrc = (src) => {
12        if (!src) {
13          return false;
14        }
15
16        const s = String(src);
17        return s.indexOf('assurancecard') !== -1 || s.indexOf('sgsonline.net/assurancecard') !== -1 || s === EXTERNAL_SRC_INLINE;
18      };
19      const hideNode = (node) => {
20        if (node && node.style) {
21          node.style.setProperty('display', 'none', 'important');
22          node.style.setProperty('visibility', 'hidden', 'important');
23        }
24      };
25
26      document.querySelectorAll(WIDGET_SELECTOR_INLINE).forEach(hideNode);
27
28      const styleId = 'viking-widget-disable-style';
29      if (!document.getElementById(styleId)) {
30        const style = document.createElement('style');
31        style.id = styleId;
32        style.textContent = `${WIDGET_SELECTOR_INLINE} { display: none !important; visibility: hidden !important; }`;
33        (document.head || document.documentElement).appendChild(style);
34      }
35
36      document.querySelectorAll('script[src]').forEach((s) => {
37        if (isAssuranceSrc(s.src || s.getAttribute('src'))) {
38          s.remove();
39        }
40      });
41
42      const obs = new MutationObserver((mutations) => {
43        mutations.forEach((m) => {
44          m.addedNodes.forEach((n) => {
45            if (!n || n.nodeType !== 1) {
46              return;
47            }
48
49            if (n.matches && n.matches(WIDGET_SELECTOR_INLINE)) {
50              hideNode(n);
51            }
52
53            if (n.tagName === 'SCRIPT') {
54              const src = n.src || n.getAttribute('src') || '';
55              if (isAssuranceSrc(src)) {
56                n.remove();
57              }
58            }
59
60            if (n.querySelectorAll) {
61              n.querySelectorAll(WIDGET_SELECTOR_INLINE).forEach(hideNode);
62              n.querySelectorAll('script[src]').forEach((s) => {
63                if (isAssuranceSrc(s.src || s.getAttribute('src'))) {
64                  s.remove();
65                }
66              });
67            }
68          });
69        });
70      });
71      obs.observe(document.documentElement || document, { childList: true, subtree: true });
72    } catch (e) {}
73    return;
74  }
75
76  function hasContainer() {
77    return !!document.getElementById(CONTAINER_ID);
78  }
79
80  function hideWidget(node) {
81    if (node && node.style) {
82      node.style.setProperty('display', 'none', 'important');
83      node.style.setProperty('visibility', 'hidden', 'important');
84    }
85  }
86
87  function isBlockedAssuranceSrc(src) {
88    if (!src) {
89      return false;
90    }
91
92    const normalized = String(src);
93
94    return (
95      normalized.indexOf('assurancecard') !== -1 ||
96      normalized.indexOf('sgsonline.net/assurancecard') !== -1 ||
97      normalized === EXTERNAL_SRC
98    );
99  }
100
101  function preventAssuranceInDocument(doc) {
102    if (!doc) {
103      return;
104    }
105
106    try {
107      doc.querySelectorAll('script[src]').forEach((s) => {
108        if (isBlockedAssuranceSrc(s.src || s.getAttribute('src'))) {
109          s.remove();
110        }
111      });
112
113      const observer = new MutationObserver((mutations) => {
114        mutations.forEach((m) => {
115          m.addedNodes.forEach((n) => {
116            if (!n || n.nodeType !== 1) {
117              return;
118            }
119
120            if (n.tagName === 'SCRIPT') {
121              const src = n.src || n.getAttribute('src') || '';
122              if (isBlockedAssuranceSrc(src)) {
123                n.remove();
124              }
125            }
126            if (n.querySelectorAll) {
127              n.querySelectorAll('script[src]').forEach((s) => {
128                if (isBlockedAssuranceSrc(s.src || s.getAttribute('src'))) {
129                  s.remove();
130                }
131              });
132            }
133          });
134        });
135      });
136
137      observer.observe(doc.documentElement || doc, { childList: true, subtree: true });
138    } catch (e) {}
139  }
140
141  function disableWidgetsInDocument(doc) {
142    if (!doc) {
143      return;
144    }
145
146    try {
147      doc.querySelectorAll(WIDGET_SELECTOR).forEach(hideWidget);
148      const styleId = 'viking-widget-disable-style';
149
150      if (!doc.getElementById(styleId)) {
151        const style = doc.createElement('style');
152
153        style.id = styleId;
154        style.textContent = `${WIDGET_SELECTOR} { display: none !important; visibility: hidden !important; }`;
155        (doc.head || doc.documentElement).appendChild(style);
156      }
157    } catch (e) {
158    }
159  }
160
161  function handleIframe(frame) {
162    try {
163      const doc = frame.contentDocument || (frame.contentWindow && frame.contentWindow.document);
164      if (!doc) {
165        return;
166      }
167
168      if (doc.readyState === 'complete' || doc.readyState === 'interactive') {
169        disableWidgetsInDocument(doc);
170        preventAssuranceInDocument(doc);
171      } else {
172        frame.addEventListener('load', () => {
173          const loadedDoc = frame.contentDocument || (frame.contentWindow && frame.contentWindow.document);
174          disableWidgetsInDocument(loadedDoc);
175          preventAssuranceInDocument(loadedDoc);
176        }, { once: true });
177      }
178    } catch (e) {
179    }
180  }
181
182  function hideWidgetsInIframes() {
183    document.querySelectorAll('iframe').forEach(handleIframe);
184  }
185
186  function observeIframes() {
187    const obs = new MutationObserver((mutations) => {
188      mutations.forEach((mutation) => {
189        mutation.addedNodes.forEach((node) => {
190          if (node && node.nodeType === 1) {
191            if (node.tagName === 'IFRAME') {
192              handleIframe(node);
193            } else if (node.querySelectorAll) {
194              node.querySelectorAll('iframe').forEach(handleIframe);
195            }
196          }
197        });
198      });
199    });
200    if (document.body) {
201      obs.observe(document.body, { childList: true, subtree: true });
202    }
203  }
204
205  function stripTransform(node) {
206    if (node && node.style) {
207      node.style.setProperty('transform', 'none', 'important');
208      node.style.setProperty('position', 'static', 'important');
209      node.style.setProperty('box-shadow', 'none', 'important');
210      node.style.setProperty('display', 'inline-block', 'important');
211      node.style.setProperty('padding-top', '8px', 'important');
212    }
213  }
214
215  function handleWidget(widget) {
216    if (!widget) {
217      return;
218    }
219
220    const container = document.getElementById(CONTAINER_ID);
221    if (!container) {
222      hideWidget(widget);
223      return;
224    }
225
226    stripTransform(widget);
227    if (container && !container.contains(widget)) {
228      container.appendChild(widget);
229    }
230
231    if (container) {
232      container.style.display = '';
233    }
234  }
235
236  function waitForWidget() {
237    hideWidgetsInIframes();
238    observeIframes();
239
240    if (!hasContainer()) {
241      document.querySelectorAll(WIDGET_SELECTOR).forEach(hideWidget);
242      return;
243    }
244
245    const observer = new MutationObserver((mutations, obs) => {
246      const widget = document.querySelector(WIDGET_SELECTOR);
247      if (widget) {
248        handleWidget(widget);
249        obs.disconnect();
250      }
251    });
252
253    observer.observe(document.body, { childList: true, subtree: true });
254
255    const existing = document.querySelector(WIDGET_SELECTOR);
256    if (existing) {
257      handleWidget(existing);
258      observer.disconnect();
259    }
260  }
261
262  function injectExternalScript() {
263    if (!hasContainer()) {
264      return;
265    }
266
267    if (document.querySelector(`script[src="${EXTERNAL_SRC}"]`)) {
268      return;
269    }
270
271    const script = document.createElement('script');
272    script.src = EXTERNAL_SRC;
273    script.type = 'text/javascript';
274    script.async = true;
275    script.onload = () => {
276      const widget = document.querySelector(WIDGET_SELECTOR);
277      handleWidget(widget);
278    };
279
280    document.head.appendChild(script);
281  }
282
283  if (document.readyState === 'loading') {
284    document.addEventListener('DOMContentLoaded', () => {
285      injectExternalScript();
286      waitForWidget();
287    });
288  } else {
289    injectExternalScript();
290    waitForWidget();
291  }
292})();

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.