Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

110
Views
Canvas added to YouTube is not visible

I'm following the WebGL tutorial from MDN (code, demo (black rectangle)) to create a WebGL canvas.

The goal is a userscript (with WebGL shaders, i.e. video effects) for YouTube. So I opened a YouTube video page and put the code below (from the link above) into the JavaScript console. The canvas got created, but it is invisible.

The canvas inherits a lot of CSS from YouTube by default. Am I overlooking some CSS properties that make it invisible? What to look out for in such cases? It should be black.

let container = document.getElementsByClassName( 'video-stream html5-main-video' )[0].parentElement;
let canvas = document.createElement('canvas')
canvas.setAttribute('id', 'glcanvas')
canvas.setAttribute('width', '1000')
canvas.setAttribute('height', '1000')
container.appendChild(canvas)

// Initialize the GL context
const gl = canvas.getContext("webgl");

// Set clear color to black, fully opaque
gl.clearColor(0.0, 0.0, 0.0, 1.0);
// Clear the color buffer with specified clear color
gl.clear(gl.COLOR_BUFFER_BIT);

enter image description here

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Your canvas is there, but it's not on-top. Set some additional CSS for positioning. For example:

position: fixed;
z-index: 1000;
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!