Skip to content

Instantly share code, notes, and snippets.

@wilmoore
Last active July 5, 2024 20:50
Show Gist options
  • Select an option

  • Save wilmoore/5b93f0e9fa97dbfa4ddbd311b67a8036 to your computer and use it in GitHub Desktop.

Select an option

Save wilmoore/5b93f0e9fa97dbfa4ddbd311b67a8036 to your computer and use it in GitHub Desktop.
Software Engineering :: Web :: Browser :: Extension :: Development :: Gist Template

Software Engineering :: Web :: Browser :: Extension :: Development :: Gist Template

⪼ Made with 💜 by Polyglot.

reference

...

related

Templates

...

Child Document
# {CurrentDocumentTitle} :: {PromptFor|Title}
>⪼ Made with 💜 by [Polyglot](https://realpolyglot.com).

- [..]({window.location.href})
Sibling Document
# {CurrentDocumentTitle|ReplaceLastSegment(":").With({PromptFor|Title}))}
>⪼ Made with 💜 by [Polyglot](https://realpolyglot.com).

- [..]({window.location.href}) // NOTE: this will be more difficut because we'd need to either copy the current document's back-link or, go down a level and retrive it, which, might not be straight-forward or even possible.

Code Spike

Given the HTML <div itemprop="about">Income Sources :: Writing :: Books :: Inspiration</div>

The following code
document.querySelector('[itemprop="about"]').textContent.trim()
returns...
"Income Sources :: Writing :: Books :: Inspiration"

Generating a child document

# Income Sources :: Writing :: Books :: Inspiration :: Private Views - A High-Rise Panorama of Manhattan
Before
# Income Sources :: Writing :: Books :: Inspiration
After
# Income Sources :: Writing :: Books :: Inspiration :: Private Views - A High-Rise Panorama of Manhattan

Generating a sibling document

# Income Sources :: Writing :: Books :: Inspiration :: Private Views - A High-Rise Panorama of Manhattan
Before
# Income Sources :: Writing :: Books :: Inspiration :: Private Views - A High-Rise Panorama of Manhattan
After
# Income Sources :: Writing :: Books :: Inspiration :: Writing for Software Developers

Getting the ID of the current document

Current URL
https://gist.github.com/wilmoore/771b820e668334390cd2d8b95cccf299
The ID is the last segment of the pathname
window.location.pathname.split('/').pop()
returns...
"771b820e668334390cd2d8b95cccf299"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment