The source code of the Chrome extension Anti-CORS, anti-CSP is described in detail in https://marian-caikovski.medium.com/how-to-bypass-cors-and-csp-policies-and-enable-cross-origin-requests-in-a-browser-47fe269500fb
The extension can be installed from the Chrome Web Store https://chromewebstore.google.com/detail/anti-cors-anti-csp/fcbmpcbjjphnaohicmhefjihollidgkp or loaded unpacked
Feel free to reuse the code