Add scripts/neocities-edit-button.js
This commit is contained in:
parent
7dcf7d5012
commit
59a2958035
1 changed files with 16 additions and 0 deletions
16
scripts/neocities-edit-button.js
Normal file
16
scripts/neocities-edit-button.js
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
// 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>
|
||||||
Loading…
Reference in a new issue