如何使用 Tampermonkey 禁用/绕过内容安全策略

问题描述 投票:0回答:1

所以我使用 firebase auth 连接到我在 tampermonkey 中制作的小型网络应用程序

auth.signInWithEmailAndPassword(email, password)

问题是当我在目标页面上使用它时,内容被阻止,因为

Content-Security-Policy
但这可以在 Firefox 中通过禁用 Content-Security-Policy

来修复

我尝试了什么

1 / 使用此脚本获取数据

fetch(auth.signInWithEmailAndPassword(email, password))
https://github.com/mitchellmebane/GM_fetch/blob/master/GM_fetch.js

2/ GM.xmlHttpRequest

GM.xmlHttpRequest({
  method: "POST",
  url: "...googleapis.com/v1/accounts:signInWithCustomToken?key="bla..bla",
 headers: {
    "Content-Type": "application/json"
  },
   data: {"email":email,"password":password,"returnSecureToken":true},

 onload: function(response) {
   auth.signInWithEmailAndPassword(email, password)

  }
})

3 / Chrome 扩展

https://chrome.google.com/webstore/detail/disable-content-security/ieelmcmcagommmplceebfedjlakkhpden?hl=en

javascript firebase-authentication greasemonkey content-security-policy tampermonkey
1个回答
0
投票

GM.xmlHttpRequest为我工作。示例:

// @grant    GM.xmlHttpRequest

const response = await GM.xmlHttpRequest({
    method: "GET",
    url: "https://example-website.com/api/people,
});
© www.soinside.com 2019 - 2024. All rights reserved.