Skip to content

Instantly share code, notes, and snippets.

@amarao
Created July 26, 2025 09:56
Show Gist options
  • Save amarao/1c4b218ed04fb3c669f09ba8903c9e75 to your computer and use it in GitHub Desktop.
Save amarao/1c4b218ed04fb3c669f09ba8903c9e75 to your computer and use it in GitHub Desktop.
random snippet from reddit
let n,e=null;async function i(){return e||(e=async function(){if(n=window.navigation,!n){console.log("Navigation API not supported, loading polyfill");try{const{applyPolyfill:e}=await import("./apply-polyfill-abfabee6.js");n=e()}catch{console.log("Navigation polyfill failed to initialize.")}}}()),e}!function(n,e,o,t,a,d,r){var c=!1,l=!1,s=[],f=function(n){("e"in n||"p"in n||n.f&&n.f.indexOf("capture")>-1||n.f&&n.f.indexOf("withScope")>-1||n.f&&n.f.indexOf("showReportDialog")>-1)&&u(s),f.data.push(n)};function u(e){function o(){i().then((()=>import("https://www.redditstatic.com/shreddit/sentry-bc0d3b33.js"))).then((i=>{try{n[d]=i.default,n[t]=p,n[a]=h;var o=n[d],c=o.init;o.init=function(n){var e=r;for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i]);c(e)},function(e,i){try{for(var o=f.data,d=0;d<e.length;d++)"function"==typeof e[d]&&e[d]();var r=!1,c=n.__SENTRY__;void 0!==c&&c.hub&&c.hub.getClient()&&(r=!0);var l=!1;for(d=0;d<o.length;d++)if(o[d].f){l=!0;var s=o[d];!1===r&&"init"!==s.f&&i.init(),r=!0,i[s.f].apply(i,s.a)}!1===r&&!1===l&&i.init();var u=n[t],p=n[a];for(d=0;d<o.length;d++)"e"in o[d]&&u?u.apply(n,o[d].e):"p"in o[d]&&p&&p.apply(n,[o[d].p])}catch(n){console.error(n)}}(e,o)}catch(n){console.error(n)}}))}l||(l=!0,"requestIdleCallback"in window?requestIdleCallback(o,{timeout:3e3}):window.setTimeout(o,0))}f.data=[],n[d]=n[d]||{},n[d].onLoad=function(n){s.push(n),c&&u(s)},n[d].forceLoad=function(){c=!0,setTimeout((function(){u(s)}))},["init","addBreadcrumb","captureMessage","captureException","captureEvent","configureScope","withScope","showReportDialog"].forEach((function(e){n[d][e]=function(){f({f:e,a:arguments})}}));var p=n[t];n[t]=function(e,i,o,t,a){f({e:[].slice.call(arguments)}),p&&p.apply(n,arguments)};var h=n[a];n[a]=function(e){f({p:"reason"in e?e.reason:"detail"in e&&"reason"in e.detail?e.detail.reason:e}),h&&h.apply(n,arguments)}}(window,document,0,"onerror","onunhandledrejection","Sentry",{dsn:"https://[email protected]/5810803"});var o=/Edge?\/(1{2}[6-9]|1[2-9]\d|[2-9]\d{2}|\d{4,})\.\d+(\.\d+|)|Firefox\/(1{2}[7-9]|1[2-9]\d|[2-9]\d{2}|\d{4,})\.\d+(\.\d+|)|Chrom(ium|e)\/(4[1-9]|[5-9]\d|\d{3,})\.\d+(\.\d+|)([\d.]+$|.*Safari\/(?![\d.]+ Edge\/[\d.]+$))|(Maci|X1{2}).+ Version\/(15\.\d+|(1[6-9]|[2-9]\d|\d{3,})\.\d+)([,.]\d+|)( \(\w+\)|)( Mobile\/\w+|) Safari\/|Chrome.+OPR\/(10[1-9]|1[1-9]\d|[2-9]\d{2}|\d{4,})\.\d+\.\d+|(CPU[ +]OS|iPhone[ +]OS|CPU[ +]iPhone|CPU IPhone OS|CPU iPad OS)[ +]+(15[._]\d+|(1[6-9]|[2-9]\d|\d{3,})[._]\d+)([._]\d+|)/;const t=["window.performance.mark is not a function","performance.getEntriesByName is not a function","window.queueMicrotask is not a function","runCustomize is not defined","require is not defined","n.assignedElements is not a function","SymBrowser_ModifyAnchorTagWithTarget","ibFindAllVideos","Unexpected token 'for'"],a=["findTopmostVisibleElement"],d=n=>{const e=(i=navigator.userAgent,!o.test(i));var i;return!!((n=>!!t.some((e=>n?.originalException?.message?.includes(e))))(n)||(n=>!!a.some((e=>n?.originalException?.stack?.includes(e))))(n)||e)};window.Sentry.onLoad((async()=>{await i(),window.Sentry.init({enabled:SENTRY_CONFIG.enabled,dsn:SENTRY_CONFIG.dsn,environment:SENTRY_CONFIG.environment,release:"d8e410898fd0014ee1de50fff2c1cc299e6bda64",beforeSend:(n,e)=>d(e)?null:(fetch("/svc/shreddit/sentryMetrics",{method:"POST",body:""}),n),sampleRate:.001})}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment