How to embed JavaScript as a customisation?


(Philip Colmer) #1

Continuing the discussion from How to restrict account changes when authenticating with Google?:

I want to try and embed some JavaScript into the Discourse pages so that if the page contains the “Create New Account” panel, the text fields are all disabled. However, I’m struggling to even get my script to appear in the page source code.

I’ve tried Header and Top in turn to embed:

<!DOCTYPE html>
<script>
    document.getElementById('input#new-account-name').setAttribute('disabled');
</script>

but I cannot see it being added to the page. I’ve included the DOCTYPE part because the customization page puts up a warning indicator otherwise. However, the HEADER code in Sam’s personal “minimal” topic list design doesn’t have that. Instead, it has:

<script type='text/x-handlebars' data-template-name='list/topic-list-item.raw'>

Where can I find out how the customisations page works and what is possible with it?