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

164
Views
Content Security Policy Error on my Google Chrome extension

i am making a Google Chrome extensions that should download mp4 files that are detected on the website page i'm on but i can't run my function that are on my script tags and i can't figure how to fix this. I got 2 errors, both related on the CSP:

Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-F7oiGRIrds+2B67r3VVNsXI1RXzWT/pYKihh3o3t4mg='), or a nonce ('nonce-...') is required to enable inline execution.

and

Refused to execute inline event handler because it violates the following Content Security Policy directive: "script-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline execution. Note that hashes do not apply to event handlers, style attributes and javascript: navigations unless the 'unsafe-hashes' keyword is present.

Here is my code:

        <header>
            <div class="d_button">
                <a id="download_b" href="files" download="video.mp4">Download</a>
            </div>
        </header>

        <script>
            document.getElementById("download_b").addEventListener("click", search4vid);
            function search4vid();
                const types = /\.(|mp4)/
                const files = performance.getEntriesByType('resource').filter(resource => resource.name.match(types) !== null).reduce((accum, value) => {
                accum[value.name.split('/')[value.name.split('/').length - 1]] = value.name
                return accum}, {})
            document.getElementById('download_b').setAttribute("href",link);
            document.getElementById('download_b').innerHTML = link;
        </script>

My javascript code is surely wrong but i can't test it. The javascript function should activate when clicking on a html text and replace an href="" by the JS variable types to then download it. It may be a little confusing and it is to me too but i'm trying my best. Thanks

about 4 years ago · Juan Pablo Isaza
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!