misc-etc/scripts/neocities-edit-button.js

16 lines
692 B
JavaScript
Raw Normal View History

2026-06-09 12:31:43 +00:00
// use this to create a quick link to edit whatever page of the site you're currently visiting. if a user of your site who isnt you but is
// logged in to neocities clicks it, it will take them to the edit page of their own account
// for the file that corresponds to whatever url you were visiting. it's very basic lol.
<script>
function url_replace() {
const path = window.location.pathname.replace(/\//g, '') ;
let html = ".html"
const base_url = 'https://neocities.org/site_files/text_editor?filename=' + path + html;
document.querySelector('.editlink').innerHTML =
`<a href="${base_url}">Edit</a>`;
}
url_replace();
</script>