PageSourceSearch

https://www.staradvertiser.com/wp-content/themes/hsa-redesign/js/general.js?ver=1.0.35

js staradvertiser.com collected 2026-09-24 08:28:39 UTC 12,479 bytes, 198 lines download raw bytes

1// Delete osano_consentmanager cookie
2function deleteOsanoCookie() {
3  document.cookie = "osano_consentmanager=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/; domain=.staradvertiser.com";
4  document.cookie = "osano_consentmanager=; max-age=0; path=/; domain=.staradvertiser.com";
5  console.log("osano_consentmanager cookie deleted");
6}
7
8// Execute immediately
9// deleteOsanoCookie();
10
11// Check cookie header size and remove cookies larger than 300 bytes if header exceeds 8KB
12function manageLargeCookies() {
13  const cookieHeader = document.cookie;
14  const cookieSize = new Blob([cookieHeader]).size;
15  const MAX_HEADER_SIZE = 5120; // 5KB in bytes
16  const LARGE_COOKIE_THRESHOLD = 25; // bytes
17  
18  // Cookie names that should not be removed
19  const cookieSkipList = [
20    'wordpress_logged_in',
21    'wordpress_sec',
22    'wp-settings-uid',
23    'wp-settings-time',
24    'osano_consentmanager',
25    'pr_token',
26  ];
27
28  console.log(`Current cookie header size: ${cookieSize} bytes`);
29  if (cookieSize > MAX_HEADER_SIZE) {
30    console.log(`Cookie header size (${cookieSize} bytes) exceeds ${MAX_HEADER_SIZE} bytes limit. Removing cookies larger than ${LARGE_COOKIE_THRESHOLD} bytes.`);
31    
32    const cookies = cookieHeader.split(';');
33    cookies.forEach((cookie) => {
34      const cookieString = cookie.trim();
35      const cookieBlob = new Blob([cookieString]).size;
36      const cookieName = cookieString.split('=')[0];
37      
38      // Check if cookie is in skip list
39      const shouldSkip = cookieSkipList.some(skipName => cookieName.includes(skipName));
40      
41      if (cookieBlob > LARGE_COOKIE_THRESHOLD && !shouldSkip) {
42        // Remove the cookie by setting max-age to 0 with multiple domain attempts
43        document.cookie = `${cookieName}=; max-age=0; path=/`;
44        document.cookie = `${cookieName}=; max-age=0; path=/; domain=.staradvertiser.com`;
45        document.cookie = `${cookieName}=; max-age=0; path=/; domain=staradvertiser.com`;
46        console.log(`Removed cookie: ${cookieName} (${cookieBlob} bytes)`);
47      } else if (cookieBlob > LARGE_COOKIE_THRESHOLD && shouldSkip) {
48        console.log(`Skipped cookie: ${cookieName} (${cookieBlob} bytes) - in skip list`);
49      }
50    });
51  }
52}
53
54// Execute immediately
55manageLargeCookies();
56
57// Mather subscribe click event listener
58function matherSubcribeClickEvent() {
59    (window._matherq = window._matherq || []).push(['paywallEvent', {type: 'subscription', category: 'payment', action: 'subscription_started'}, false]);
60}
61
62// comScore
63var _comscore = _comscore || [];
64_comscore.push({ c1: "2", c2: "6035032" });
65(function() {
66    var s = document.createElement("script"), el = document.getElementsByTagName("script")[0]; s.async = true;
67    s.src = (document.location.protocol == "https:" ? "https://sb" : "http://b") + ".scorecardresearch.com/beacon.js";
68    el.parentNode.insertBefore(s, el);
69})();
70
71// // Microsoft Clarity
72// (function(c,l,a,r,i,t,y){
73//     c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
74//     t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
75//     y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
76// })(window, document, "clarity", "script", "c13p8ejhds");
77
78// Kissmetrics
79var _kmk = _kmk || '1f177fde1be2a71ccc3da4ab0b377bb91e9a3801';
80function _kms(u){
81setTimeout(function(){
82    var d = document, f = d.getElementsByTagName('script')[0],
83    s = d.createElement('script');
84    s.type = 'text/javascript'; s.async = true; s.src = u;
85    f.parentNode.insertBefore(s, f);
86}, 1);
87}
88_kms('//i.kissmetrics.io/i.js');
89_kms('//scripts.kissmetrics.io/' + _kmk + '.2.js');
90
91// Admiral GPP
92// !(function(o,_name){o[_name]=o[_name]||function $(){($.q=$.q||[]).push(arguments)},o[_name].v=o[_name].v||2;!(function(o,t,n,f,e,i){function c(f,e){(f=(function(t,n){try{if(n=(t=o.localStorage).getItem("_aQS02M0MwNjQyMDJGRDgwODVENzRFMDEwQTYtMQ"))return JSON.parse(n).lgk||[];if((t.getItem("v4ac1eiZr0")||"").split(",")[4]>0)return[[_name+"-engaged","true"]]}catch(f){}})())&&typeof f.forEach===n&&(e=o[t].pubads())&&f.forEach((function(o){o&&o[0]&&e.setTargeting(o[0],o[1]||"")}))}(i=o[t]=o[t]||{}).cmd=i.cmd||[],typeof i.pubads===n?c():typeof i.cmd.unshift===n?i.cmd.unshift(c):i.cmd.push(c)})(window,"googletag","function");})(window,decodeURI('a%64%6d%69%72%61l'));!(function(t,c,i){i=t.createElement(c),t=t.getElementsByTagName(c)[0],i.async=1,i.src="https://knottyswing.com/bundles/413b04722f4a/94729b7a3e867377bf62fbb5e9699c",t.parentNode.insertBefore(i,t)})(document,"script");;;!(function(t,n,e,i,a){function c(){for(var t=[],e=0;e<arguments.length;e++)t.push(arguments[e]);if(!t.length)return a;"ping"===t[0]?t[2]({gdprAppliesGlobally:!!n.__cmpGdprAppliesGlobally,cmpLoaded:!1,cmpStatus:"stub"}):t.length>0&&a.push(t)}function f(t){if(t&&t.data&&t.source){var i,a=t.source,c="string"==typeof t.data&&t.data.indexOf("__tcfapiCall")>=0;(i=c?((function(t){try{return JSON.parse(t)}catch(n){}})(t.data)||{}).__tcfapiCall:(t.data||{}).__tcfapiCall)&&n[e](i.command,i.version,(function(t,n){var e={__tcfapiReturn:{returnValue:t,success:n,callId:i.callId}};a&&a.postMessage(c?JSON.stringify(e):e,"*")}),i.parameter)}}!(function o(){if(!n.frames[i]){var e=t.body;if(e){var a=t.createElement("iframe");a.style.display="none",a.name=i,e.appendChild(a)}else setTimeout(o,5)}})(),c.v=1,"function"!=typeof n[e]&&(n[e]=n[e]||c,n.addEventListener?n.addEventListener("message",f,!1):n.attachEvent&&n.attachEvent("onmessage",f))})(document,window,"__tcfapi","__tcfapiLocator",[]);;;!(function(e,t,n,r,a,i,s,c,u,o,p){function d(){for(var e=[],t=arguments.length,n=0;n<t;n++)e.push(arguments[n]);var r,a=e[1],i=typeof a===s,c=e[2],d={gppVersion:"1.1",cmpStatus:"stub",cmpDisplayStatus:"hidden",signalStatus:"not ready",supportedAPIs:["7:usnat"].reduce((function(e,t){return t&&e.push(t),e}),[]),cmpId:9,sectionList:[],applicableSections:[0],gppString:"",parsedSections:{}};function f(e){i&&a(e,!0)}switch(e[0]){case"ping":return f(d);case"queue":return u;case"events":return o;case"addEventListener":return i&&(r=++p,o.push({id:r,callback:a,parameter:c})),f({eventName:"listenerRegistered",listenerId:r,data:!0,pingData:d});case"removeEventListener":for(r=!1,n=0;n<o.length;n++)if(o[n].id===c){o.splice(n,1),r=!0;break}return f(r);case"hasSection":case"getSection":case"getField":return f(null);default:return void u.push(e)}}d.v=2,typeof t.__gpp!==s&&(t.__gpp=t.__gpp||d,t.addEventListener&&t.addEventListener("message",(function(e,n){var r="string"==typeof e.data;(n=r?((function(e){try{return JSON.parse(e)}catch(t){}})(e.data)||{}).__gppCall:(e.data||{}).__gppCall)&&t.__gpp(n.command,(function(t,a){var i={__gppReturn:{returnValue:t,success:a,callId:n.callId}};e.source.postMessage(r?JSON.stringify(i):i,"*")}
92),"parameter"in n?n.parameter:null,n.version||1)}),!1),(function f(){if(!t.frames[r]){var n=e.body;if(n){var a=e.createElement("iframe");a.style.display="none",a.name=r,n.appendChild(a)}else setTimeout(f,5)}})())})(document,window,0,"__gppLocator",0,0,"function",0,[],[],0);
93
94
95async function enhanceExternalLinks() {
96    const urlProtocol = /^(http:|https:|\/\/)/;
97    const hsaDomain = /(.*)(\.(staradvertiser|wpengine)\.com)(.*)/;
98    const longsLink = /(.*)(longs\.staradvertiser\.com)(.*)/;
99
100    var hsaLinksAffected = [];
101    jQuery("a[href]").each(function () {
102        let href = jQuery(this).attr("href"); 
103        let urlParts = href.split('?');
104        let urlWithoutParams = ( urlParts.length >= 2 ) ? urlParts[0] : href;
105        let linkDetails = {
106            "link" : href,
107            "urlWithoutParams": urlWithoutParams,
108            "logs": []
109        };
110        if( urlProtocol.test( urlWithoutParams ) ) {
111            let isHSADomain = hsaDomain.test( urlWithoutParams );
112            let linkTarget = jQuery(this).attr("target");
113            linkDetails.target = linkTarget;
114            linkDetails.logs.push( "Matches urlProtocol check" );
115            // Checks if URL is an external link
116            if( !isHSADomain ) {
117                linkDetails.logs.push( "External Link / NOT an HSA Domain URL" );
118                linkDetails.logs.push( "Add nopener and noreferrer to rel attribute" );
119                addNoOpenerNoReferrer(this);                
120                if( linkTarget && linkTarget.toLowerCase() == '_blank' ) {
121                    linkDetails.logs.push( "Link opens in new tab" );
122                    let hasImage = jQuery(this).find('img').length;
123                    let parentClasses = 'div.sidebar, ul.social, .section-heading, .post-entry .share, .author-meta';
124                    
125                    // Add visual cue
126                    if( !( 
127                            hasImage ||                                 // Link with images
128                            jQuery(this).parents(parentClasses).length  // Child of any of parentClasses 
129                        )   
130                    ) {
131                        linkDetails.logs.push( "Add Visual Cue" );
132                        // Add screen reader only elements AND visual cue to the link
133                        this.insertAdjacentHTML( 'beforeend', '&nbsp;<span class="icon-external-link-square"></span>' );
134                    }
135                    linkDetails.logs.push( "Add screen reader only" );
136                    this.insertAdjacentHTML( 'beforeend', '<span class="visually-hidden">Opens in a new tab</span>' );
137                    
138                    // Only add tooltip if link doesn't have an image
139                    if( !hasImage ) {
140                        linkDetails.logs.push( "Add tooltip" );
141                        jQuery(this).attr("data-bs-toggle", "tooltip");
142                        jQuery(this).attr("title", "Opens a new tab");
143                        jQuery(this).attr("data-placement", "auto");
144                        let tooltip = new bootstrap.Tooltip( jQuery(this) );
145                    }
146                }
147            } else {
148                linkDetails.logs.push( "HSA Domain URL" );
149                if( linkTarget && linkTarget.toLowerCase() == '_blank' ) {
150                    linkDetails.logs.push( "Link opens in new tab" );
151                    let hasImage = jQuery(this).find('img').length;
152                    let isLongsLink = longsLink.test( urlWithoutParams );
153                    let parentClasses = 'div.sidebar, div.todays-paper, ul.social, .section-heading, .post-entry .share, .author-meta';
154                    
155                    // Add visual cue
156                    if( !( 
157                            hasImage ||                                     // Link with images
158                            isLongsLink ||                                  // Longs Link
159                            jQuery(this).parents(parentClasses).length      // Child of any of parentClasses 
160                        )    
161                    ) {
162                        linkDetails.logs.push( "Add Visual Cue" );
163                        // Add screen reader only elements AND visual cue to the link
164                        this.insertAdjacentHTML( 'beforeend', '&nbsp;<span class="icon-external-link-square"></span>' );
165                    }
166                    linkDetails.logs.push( "Add screen reader only" );
167                    this.insertAdjacentHTML( 'beforeend', '<span class="visually-hidden">Opens in a new tab</span>' );
168                    
169                    // Only add tooltip if link doesn't have an image or is not Longs
170                    if( !hasImage && !isLongsLink ) {
171                        linkDetails.logs.push( "Add tooltip" );
172                        jQuery(this).attr("data-bs-toggle", "tooltip");
173                        jQuery(this).attr("title", "Opens a new tab");
174                        jQuery(this).attr("data-placement", "auto");
175                        let tooltip = new bootstrap.Tooltip( jQuery(this) );
176                    }
177                }
178            }
179        }
180        hsaLinksAffected.push( linkDetails );
181    });
182    function addNoOpenerNoReferrer(link) {
183        let linkTypesInit = (link.getAttribute('rel') || '').split(' ');
184        let linkTypes = linkTypesInit.filter(a => a !== 'opener');
185        if (!linkTypes.includes('noopener')) {
186            linkTypes.push('noopener');
187        }
188        if (!linkTypes.includes('noreferrer')) {
189            linkTypes.push('noreferrer');
190        }
191        link.setAttribute('rel', linkTypes.join(' ').trim());
192    }
193}
194
195// On document ready
196jQuery(document).ready(function() {
197    enhanceExternalLinks();
198});

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.