Skip to content

Instantly share code, notes, and snippets.

@epidemicz
Last active August 14, 2024 22:20
Show Gist options
  • Save epidemicz/7efcac967357e31cc25d6a06782f375d to your computer and use it in GitHub Desktop.
Save epidemicz/7efcac967357e31cc25d6a06782f375d to your computer and use it in GitHub Desktop.
Copy Swagger Access Token Bookmarklet
// Find the first access token from a swagger response called 'accessToken' & copy it to the clipboard.
// Usage: drag the block of code below this line to your bookmarks bar or just make a new one and paste it as the url
javascript:(function(){
for (const e of document.querySelectorAll('.language-json')) {
const { accessToken } = JSON.parse(e.innerText);
if (accessToken && accessToken.length > 100) {
console.log(accessToken);
const text = `Bearer ${accessToken}`;
navigator.clipboard.writeText(text);
return;
}
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment