PageSourceSearch

https://www.securetechalliance.org/wp-content/mu-plugins/simply-st…/assets/ssp-search-page.js

js securetechalliance.org collected 2026-10-02 05:14:24 UTC 13,656 bytes, 2 lines download raw bytes

1"use strict";function sspGetQueryParam(name){try{const val=new URLSearchParams(window.location.search).get(name);return val||""}catch(_){return""}}function sspSafeNavigationUrl(value){try{const url=new URL(String(value||""),window.location.origin+"/");if(!/^https?:$/.test(url.protocol)||url.username||url.password)return null;const trustedOrigins=[window.location.origin];return window.ssp_search&&Array.isArray(ssp_search.trusted_navigation_origins)&&ssp_search.trusted_navigation_origins.forEach(function(origin){try{const trusted=new URL(String(origin));/^https?:$/.test(trusted.protocol)&&!trusted.username&&!trusted.password&&trustedOrigins.push(trusted.origin)}catch(_){}}),trustedOrigins.indexOf(url.origin)===-1?null:url.toString()}catch(_){return null}}function sspGetExportBase(){const marker="/wp-content/",norm=b=>b?(b.charAt(0)!=="/"&&(b="/"+b),b=b.replace(/\/+/g,"/"),b.endsWith("/")||(b+="/"),b):"/";try{const meta=document.querySelector("meta[name='ssp-config-path']");if(meta){let raw=meta.getAttribute("content")||"/";raw=String(raw).trim().replace(/^(https?)\/\//i,"$1://");const p=new URL(raw,window.location.origin+"/").pathname||"/",idx=p.indexOf(marker);if(idx!==-1){const base=p.substring(0,idx+1);return norm(base||"/")}}}catch(_){}return"/"}function sspGetLocalePrefixConsideringBase(pathname){const baseName=sspGetExportBase().replace(/^\//,"").replace(/\/$/,""),parts=pathname.split("/").filter(Boolean);let startIdx=0;baseName&&parts[0]===baseName&&(startIdx=1);const locale=parts[startIdx]||"";return locale&&locale.length===2?"/"+locale+"/":"/"}function sspReplaceTestTokens(term,scopeEl){try{let replaceInScope=function(scope){let replaced=!1;return selectors.forEach(function(sel){scope.querySelectorAll(sel).forEach(function(n){n.querySelector&&n.querySelector("#ssp-term")||n.childNodes.forEach(function(child){if(child.nodeType===Node.TEXT_NODE){const newText=child.textContent.replace(/\btest\b/gi,term);newText!==child.textContent&&(child.textContent=newText,replaced=!0)}})})}),replaced};if(!term)return;const selectors=["h1","h2","h3",".h1",".h2",".h3",".page-title",".entry-title",".archive-title",".search-title",".wp-block-query-title"],primaryScope=scopeEl||document.querySelector("main, #primary, .site-main, .content-area, .entry-content, .wp-block-post-content");if(primaryScope&&replaceInScope(primaryScope))return;replaceInScope(document.body)}catch(_){}}function sspSetHeadingTerm(){try{let term=sspGetQueryParam("s");if(!term)return;try{term=decodeURIComponent(term)}catch(_){}term=(term+"").trim();const span=document.getElementById("ssp-term");span?span.textContent=term:sspReplaceTestTokens(term)}catch(_){}}function sspAddHideNativeStyles(){try{if(document.getElementById("ssp-search-hide-native"))return;const style=document.createElement("style");style.id="ssp-search-hide-native",style.type="text/css",style.textContent=["main .search-results","main .posts","main .wp-block-query","main > article","main > .hentry","#primary .search-results","#primary > article",".site-main .search-results",".site-main > article",".content-area .search-results",".content-area > article",".wp-block-post-content .search-results"].join(`,
2`)+" { display: none !important; }",document.head.appendChild(style)}catch(_){}}function sspEnsureHeadingPlaceholder(beforeEl){try{if(document.getElementById("ssp-term"))return;const h=document.createElement("h1");h.className="ssp-search-heading",h.appendChild(document.createTextNode("Searched for: "));const term=document.createElement("span");if(term.id="ssp-term",h.appendChild(term),beforeEl&&beforeEl.parentNode)beforeEl.parentNode.insertBefore(h,beforeEl);else{const target=document.querySelector("main, #primary, .site-main, .content-area, .entry-content, .wp-block-post-content")||document.body;target.firstChild?target.insertBefore(h,target.firstChild):target.appendChild(h)}}catch(_){}}function sspInjectIntoSearchPage(){var existingSearch=document.querySelector(".ssp-search");if(existingSearch||document.querySelector(".ssp-search-container-injected")){sspSetHeadingTerm();try{let term=sspGetQueryParam("s");if(term){try{term=decodeURIComponent(term)}catch(_){}term=(term+"").trim(),document.querySelectorAll(".ssp-search .search-input").forEach(function(inputEl){if(inputEl){inputEl.value=term,inputEl.dispatchEvent(new Event("input",{bubbles:!0}));var parentForm=inputEl.closest?inputEl.closest(".search-form"):null;parentForm&&parentForm.dispatchEvent(new Event("submit",{bubbles:!0,cancelable:!0}))}})}}catch(_){}return}
2function firstMatch(selectors){if(!selectors||!selectors.length)return null;for(let i=0;i<selectors.length;i++){const sel=selectors[i];try{const node=document.querySelector(sel);if(node)return node}catch(_){}}return null}let candidates=[];window.ssp_search&&Array.isArray(ssp_search.selectors)&&(candidates=candidates.concat(ssp_search.selectors));let target=firstMatch(candidates);if(target||(target=document.querySelector("main")||document.getElementById("primary")),!target&&window.ssp_search&&ssp_search.custom_selector&&(target=firstMatch([ssp_search.custom_selector])),!target)return;const wrapper=document.createElement("div");wrapper.className="ssp-search-container-injected",window.ssp_search&&ssp_search.html?wrapper.innerHTML=ssp_search.html:wrapper.innerHTML="";const mode=window.ssp_search&&ssp_search.inject_mode?ssp_search.inject_mode:"replace";if(mode==="replace"){[".search-results",".hfeed",".posts",".wp-block-query","article.entry","article.hentry","article.post"].forEach(function(sel){try{target.querySelectorAll(sel).forEach(n=>n.style.display="none")}catch(_){}});let anchor=null;const nativeSelectors=[".search-results",".wp-block-query",".posts"];for(let i=0;i<nativeSelectors.length;i++)try{const n=target.querySelector(nativeSelectors[i]);if(n){anchor=n;break}}catch(_){}anchor&&anchor.parentNode?anchor.parentNode.insertBefore(wrapper,anchor):target.insertAdjacentElement("beforeend",wrapper)}else mode==="prepend"?target.insertAdjacentElement("afterbegin",wrapper):target.insertAdjacentElement("beforeend",wrapper);sspEnsureHeadingPlaceholder(wrapper),sspSetHeadingTerm();try{const innerSearch=wrapper.querySelector(".ssp-search");innerSearch&&innerSearch.classList.add("ssp-search--page")}catch(_){}try{const pageFormNode=wrapper.querySelector(".ssp-search");pageFormNode&&((window.ssp_search&&ssp_search.search_type?ssp_search.search_type:"fuse")==="algolia"&&typeof window.AlgoliaSearchForm=="function"?new AlgoliaSearchForm(pageFormNode):typeof FuseSearchForm=="function"&&new FuseSearchForm(pageFormNode))}catch(_){}try{const term=sspGetQueryParam("s"),inputEl=wrapper.querySelector(".search-input");if(term&&inputEl&&(inputEl.value=term,inputEl.dispatchEvent(new Event("input",{bubbles:!0})),term.length>=3)){const formEl=wrapper.querySelector(".search-form");formEl&&formEl.dispatchEvent(new Event("submit",{bubbles:!0,cancelable:!0}))}}catch(_){}}function sspIsOnStaticSearchPage(){try{let norm=function(p){return p?(p.charAt(0)!=="/"&&(p="/"+p),p=p.replace(/\/+/g,"/"),p.length>1&&p.endsWith("/")&&(p=p.slice(0,-1)),p):"/"},pathsEquivalent=function(currentPath,expected){const cur=norm(currentPath),exp=norm(expected);if(cur===exp)return!0;if(exp.endsWith("/index.html")){const expDir=exp.slice(0,-11);if(cur===expDir)return!0}return!1};if(!!!document.querySelector("meta[name='ssp-config-path']"))return!1;const staticPath=window.ssp_search&&ssp_search.static_search_path?ssp_search.static_search_path:"/__qs/index.html",base=sspGetExportBase(),localePrefix=sspGetLocalePrefixConsideringBase(window.location.pathname),expectedPath=base.replace(/\/$/,"/")+(localePrefix==="/"?"":localePrefix.replace(/^\//,""))+staticPath.replace(/^\//,"");return pathsEquivalent(window.location.pathname,expectedPath)}catch(_){return!1}}function sspMaybeRedirectForSearch(){try{const term=sspGetQueryParam("s");if(!term||sspIsOnStaticSearchPage())return;let isStatic=!!document.querySelector("meta[name='ssp-config-path']");if(!isStatic){const base=sspGetExportBase();base&&base!=="/"&&(isStatic=!0)}if(!isStatic&&window.ssp_search)try{new URL(ssp_search.search_url||"/?s=SSP_PLACEHOLDER",window.location.origin).host!==window.location.host&&(isStatic=!0)}catch(_){}let target=null;if(isStatic){let pathsEquivalent=function(currentPath,expected){function norm(p){return p?(p.charAt(0)!=="/"&&(p="/"+p),p=p.replace(/\/+/g,"/"),p.length>1&&p.endsWith("/")&&(p=p.slice(0,-1)),p):"/"}const cur=norm(currentPath),exp=norm(expected);if(exp.endsWith("/index.html")){const expDir=exp.slice(0,-11);if(cur===expDir)return!0}return cur===exp};const staticPath=window.ssp_search&&ssp_search.static_search_path?ssp_search.static_search_path:"/__qs/index.html",base=sspGetExportBase(),localePrefix=sspGetLocalePrefixConsideringBase(window.location.pathname);let expectedPath=base.replace(/\/$/,"/")+(localePrefix==="/"?"":localePrefix.replace(/^\//,""))+staticPath.replace(/^\/+/,"");if(expectedPath.charAt(0)!=="/"&&(expectedPath="/"+expectedPath),!pathsEquivalent(window.location.pathname,expectedPath)){const url=new URL(expectedPath,window.location.origin);url.search="",url.searchParams.set("s",term),target=url.toString()}}else if(window.ssp_search){if(ssp_search.is_search===!0)return;const base=ssp_search.search_url||window.location.origin+"/?s="+(ssp_search.search_placeholder||"SSP_PLACEHOLDER"),placeholder=ssp_search.search_placeholder||"SSP_PLACEHOLDER";if(base.indexOf(placeholder)!==-1)target=base.replace(placeholder,encodeURIComponent(term));else{const url=new URL(base,window.location.origin);url.searchParams.set("s",term),target=url.toString()}}target=sspSafeNavigationUrl(target),target&&target!==window.location.href&&window.location.replace(target)}catch(_){}}function sspInitSearchPageIfNeeded(){try{let getMainForm=function(){var scope=document.querySelector("main, #primary, .site-main, .content-area, .entry-content, .wp-block-post-content")||document.body;return scope.querySelector(".ssp-search")||document.querySelector(".ssp-search")},waitFor=function(cond,timeoutMs,stepMs){return new Promise(function(resolve){var t0=Date.now(),step=stepMs||50,timeout=timeoutMs||3e3;(function tick(){try{if(cond()){resolve(!0);return}}catch(_){}if(Date.now()-t0>=timeout){resolve(!1);return}setTimeout(tick,step)})()})},waitForFuseReady=function(){return new Promise(function(resolve){var done=!1;function finish(){done||(done=!0,resolve(!0))}setTimeout(finish,0),window.addEventListener("ssp:fuse-ready",finish,{once:!0})})},waitForFormInit=function(form){return waitFor(function(){try{return form&&form.dataset&&form.dataset.sspFuseInit==="1"}catch(_){return!1}},3e3,50)};if(!sspIsOnStaticSearchPage())return;sspAddHideNativeStyles(),sspSetHeadingTerm(),sspInjectIntoSearchPage(),(function(){try{let populateInputs=function(){var allInputs=document.querySelectorAll(".ssp-search .search-input"),populated=!1;
2return allInputs.forEach(function(inp){try{inp.value=term,inp.dispatchEvent(new Event("input",{bubbles:!0})),populated=!0}catch(_){}}),populated&&allInputs.length>0},retriggerInputs=function(){var inputs=document.querySelectorAll(".ssp-search .search-input");inputs.forEach(function(inp){try{if((!inp.value||inp.value!==term)&&(inp.value=term),(inp.value||"").trim().length>=3){inp.dispatchEvent(new Event("input",{bubbles:!0}));var parentForm=inp.closest?inp.closest(".search-form"):null;parentForm&&parentForm.dispatchEvent(new Event("submit",{bubbles:!0,cancelable:!0}))}}catch(_){}})};var term=sspGetQueryParam("s");try{term=decodeURIComponent(term||"")}catch(_){}if(term=(term+"").trim(),!term)return;populateInputs();var retryDelays=[50,100,200,500,1e3];retryDelays.forEach(function(delay){setTimeout(function(){var inputs=document.querySelectorAll(".ssp-search .search-input");inputs.forEach(function(inp){try{(!inp.value||inp.value!==term)&&(inp.value=term,inp.dispatchEvent(new Event("input",{bubbles:!0})))}catch(_){}})},delay)}),window.addEventListener("ssp:fuse-ready",retriggerInputs,{once:!0}),window.addEventListener("ssp:index-ready",retriggerInputs,{once:!0})}catch(_){}})()}catch(_){}}function sspAttachSubmitRedirect(scopeEl){try{if(sspIsOnStaticSearchPage())return;const forms=(scopeEl||document).querySelectorAll(".ssp-search .search-form");if(!forms||!forms.length)return;forms.forEach(function(form){form.dataset&&form.dataset.sspSubmitBound==="1"||(form.addEventListener("submit",function(event){try{event.preventDefault();const input=form.querySelector(".search-input");let term=input&&input.value||"";if(term=(term+"").trim(),!term)return input&&input.focus(),!1;const staticPath=window.ssp_search&&ssp_search.static_search_path?ssp_search.static_search_path:"/__qs/index.html",base=sspGetExportBase(),localePrefix=sspGetLocalePrefixConsideringBase(window.location.pathname);let targetPath=base.replace(/\/$/,"/")+(localePrefix==="/"?"":localePrefix.replace(/^\//,""))+staticPath.replace(/^\//,"");targetPath.charAt(0)!=="/"&&(targetPath="/"+targetPath);const url=new URL(targetPath,window.location.origin);return url.search="",url.searchParams.set("s",term),window.location.assign(url.toString()),!1}catch(_){}},!0),form.dataset&&(form.dataset.sspSubmitBound="1"))})}catch(_){}}(function(){function initWhenReady(){try{sspMaybeRedirectForSearch()}catch(_){}try{sspAttachSubmitRedirect()}catch(_){}sspInitSearchPageIfNeeded()}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",initWhenReady):initWhenReady(),window.addEventListener("ssp:fuse-ready",function(){try{sspInitSearchPageIfNeeded()}catch(_){}try{sspAttachSubmitRedirect()}catch(_){}}),window.addEventListener("ssp:index-ready",function(){try{sspInitSearchPageIfNeeded()}catch(_){}})})();

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.