1

I’m trying to display some ASCII art to show inside the Elements tab—NOT console.log—when someone inspects a webage.

I’m using React, so I don’t have access to the final build, which happens on the server. How and where do I insert this ASCII string to show?

5
  • 1
    It's just a HTML <!-- comment -->, right? Commented Jul 12, 2023 at 13:10
  • 2
    "How and where do I insert this ASCII string to show?" - in JS you could set it using innerHTML, or even the lower-level DOM Node API (which predates the Element-based DOM API we use today): stackoverflow.com/questions/17931846/… Commented Jul 12, 2023 at 13:11
  • 1
    @Dai, No, because comments are stripped at build time. Commented Jul 12, 2023 at 13:18
  • 1
    Right, that's why I suggested using the DOM API to insert new comments via JS. Commented Jul 12, 2023 at 13:18
  • 1
    @Dai Oops, didn’t realise you added both these comments, I was just replying to your first comment, ha. Commented Jul 12, 2023 at 13:20

1 Answer 1

0

A bit rusty, but like this?

const c = document.createComment( `
   ____     __   ,-----.      ___    _            .-'''-. .---.  .---.     ,-----.      ___    _   .---.      ______             .-------.   .---.        ____    ,---.   .--.,---------.         ,---.    ,---.    ,-----.    .-------.        .-''-.           ________   .---.       ,-----.    .--.      .--.    .-''-.  .-------.       .-'''-.  
   \   \   /  /.'  .-,  '.  .'   |  | |          / _     \|   |  |_ _|   .'  .-,  '.  .'   |  | |  | ,_|     |    _ \`''.         \  _(\`)_ \  | ,_|      .'  __ \`. |    \  |  |\          \        |    \  /    |  .'  .-,  '.  |  _ _   \     .'_ _   \         |        |  | ,_|     .'  .-,  '.  |  |_     |  |  .'_ _   \ |  _ _   \     / _     \ 
    \  _. /  '/ ,-.|  \ _ \ |   .'  | |         (\`' )/\`--'|   |  ( ' )  / ,-.|  \ _ \ |   .'  | |,-./  )     | _ | ) _  \        | (_ o._)|,-./  )     /   '  \  \|  ,  \ |  | \`--.  ,---'        |  ,  \/  ,  | / ,-.|  \ _ \ | ( ' )  |    / ( \` )   '        |   .----',-./  )    / ,-.|  \ _ \ | _( )_   |  | / ( \` )   '| ( ' )  |    (\`' )/\`--' 
     _( )_ .';  \  '_ /  | :.'  '_  | |        (_ o _).   |   '-(_{;}_);  \  '_ /  | :.'  '_  | |\  '_ '\`)   |( ''_'  ) |        |  (_,_) /\  '_ '\`)   |___|  /  ||  |\_ \|  |    |   \           |  |\_   /|  |;  \  '_ /  | :|(_ o _) /   . (_ o _)  |        |  _|____ \  '_ '\`) ;  \  '_ /  | :|(_ o _)  |  |. (_ o _)  ||(_ o _) /   (_ o _).    
 ___(_ o _)' |  _\`,/ \ _/  |'   ( \.-.|         (_,_). '. |      (_,_) |  _\`,/ \ _/  |'   ( \.-.| > (_)  )   | . (_) \`. |        |   '-.-'  > (_)  )      _.-\`   ||  _( )_\  |    :_ _:           |  _( )_/ |  ||  _\`,/ \ _/  || (_,_).' __ |  (_,_)___|        |_( )_   | > (_)  ) |  _\`,/ \ _/  || (_,_) \ |  ||  (_,_)___|| (_,_).' __  (_,_). '.  
|   |(_,_)'  : (  '\_/ \   ;' (\`. _\` /|        .---.  \  :| _ _--.   | : (  '\_/ \   ;' (\`. _\` /|(  .  .-'   |(_    ._) '        |   |     (  .  .-'   .'   _    || (_ o _)  |    (_I_)           | (_ o _) |  |: (  '\_/ \   ;|  |\ \  |  |'  \   .---.        (_ o._)__|(  .  .-' : (  '\_/ \   ;|  |/    \|  |'  \   .---.|  |\ \  |  |.---.  \  : 
|   \`-'  /    \ \`"/  \  ) / | (_ (_) _)        \    \`-'  ||( ' ) |   |  \ \`"/  \  ) / | (_ (_) _) \`-'\`-'|___ |  (_.\.' /         |   |      \`-'\`-'|___ |  _( )_  ||  (_,_)\  |   (_(=)_)          |  (_,_)  |  | \ \`"/  \  ) / |  | \ \`'   / \  \`-'    /        |(_,_)     \`-'\`-'|___\ \`"/  \  ) / |  '  /\  \`  | \  \`-'    /|  | \ \`'   /\    \`-'  | 
 \      /      '. \_/\`\`".'   \ /  . \ /         \       / (_{;}_)|   |   '. \_/\`\`".'   \ /  . \ /  |        \|       .'          /   )       |        \\ (_ o _) /|  |    |  |    (_I_)           |  |      |  |  '. \_/\`\`".'  |  |  \    /   \       /         |   |       |        \'. \_/\`\`".'  |    /  \    |  \       / |  |  \    /  \       /  
  \`-..-'         '-----'      \`\`-'\`-''           \`-...-'  '(_,_) '---'     '-----'      \`\`-'\`-''   \`--------\`'-----'\`            \`---'       \`--------\` '.(_,_).' '--'    '--'    '---'           '--'      '--'    '-----'    ''-'   \`'-'     \`'-..-'          '---'       \`--------\`  '-----'    \`---'    \`---\`   \`'-..-'  ''-'   \`'-'    \`-...-'   
                                                                                                                                                                                                                                                                                                                                                                                                              

` );
document.head.insertBefore( c, document.head.firstElementChild );

Screenshot:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.