Last active
January 10, 2022 16:30
-
-
Save VorticonCmdr/bbfa9f4384b252063ff990ac1e64612c to your computer and use it in GitHub Desktop.
tagManager functions for SEO
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// returns textFragment | |
function() { | |
if (!performance) { | |
return 'n/a'; | |
} | |
var p = performance.getEntriesByType('navigation'); | |
if (p.length < 1) { | |
return 'navigation missing'; | |
} | |
var u = p[0].name.match("#:~:text=(.*)"); | |
if (!u) { | |
return 'no match'; | |
} | |
var entries = decodeURIComponent(u[1]); | |
return entries.replace(/, /g,"*").replace(/,/g,"...").replace(/\*/g,", "); | |
} | |
// returns number of redirects | |
function () { | |
if (!performance) { | |
return 'n/a'; | |
} | |
var p = performance.getEntriesByType('navigation'); | |
if (p.length < 1) { | |
return 'navigation missing'; | |
} | |
return p[0].redirectCount; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment