Add content of JS file in Confluence Admin > Custom HTML
See: https://confluence.atlassian.com/confkb/how-to-use-javascript-in-confluence-313458839.html
Add the tag %automaticnumbering% to the page. All headings will now receive automatic numbering.