这是我第一次使用javascript和chrome扩展程序。我想在法定网址的末尾附加?share=1
,所以我不必注册。我尝试查看了一些答案,但无法找到为什么在URL末尾将此字符串附加两次?share=1?shared=1
。
这是我的代码
{
"manifest_version": 2,
"name": "Quora view",
"description": "View quora without signing up ",
"version": "1.0.0",
"icons": {"128": "icon128.png"},
"background": {"scripts":["background.js"]},
"permissions": [
"activeTab",
"webRequest",
"*://www.quora.com/*",
"webRequestBlocking"
]}
let host = "https://www.quora.com";
let post = "?share=1";
chrome.webRequest.onBeforeRequest.addListener(
function(details) {
return {redirectUrl: host + details.url.match(/^https?:\/\/[^\/]+[\S\s]*)/)[1] + post};
},
{
urls: [
"*://www.quora.com/*",
]
},
["blocking"]
);