我在rules.json中使用addOrReplaceParams,但似乎只能添加或替換鍵值對,但我只想修改鍵名,有什么辦法嗎?例如,我想修改引數名稱 postID 為 po。
https://www.blogger.com/comment/frame/5235590154125226279?postID=9028051665011570908&hl=zh-CN&blogspotRpcToken=942236&parentID=7864247129676677521#
這是我的rules.json,它重定向得很好,但我不知道如何獲得原始url postID的值9028051665011570908
[{
"id": 1,
"priority": 1,
"action": {
"type": "redirect",
"redirect": {
"transform": {
"queryTransform": {
"removeParams": ["postID"],
"addOrReplaceParams": [
{
"key": "po",
"value": how to gain postID's value
}
]
}
}
}
},
"condition": {
"urlFilter": "blogger.com/comment/frame",
"resourceTypes": ["main_frame"]
}
}]
我已閱讀下面的檔案,但找不到任何解決方案 3-72-0-dot-chrome-apps-doc.appspot.com developer.chrome.com
uj5u.com熱心網友回復:
沒有這樣的操作,所以你可以建議在https://crbug.com上實作它。
解決方法是使用 regexFilter regexSubstitution。
它通常較慢,但對于像這樣的簡單運算式來說并沒有多少,特別是如果我們指定requestDomains限制規則。
[{
"id": 1,
"action": {
"type": "redirect",
"redirect": {
"regexSubstitution": "\\1po="
}
},
"condition": {
"requestDomains": ["blogger.com"],
"regexFilter": "(/comment/frame[^#]*?[?&])postID=",
"resourceTypes": ["main_frame"]
}
}]
要測驗運算式,您可以使用 devtools 控制臺:
"https://www.blogger.com/comment/frame?postID=123"
.replace(RegExp("(/comment/frame[^#]*?[?&])postID="),
"\\1po=".replace(/\\(?=\d)/g, '$'))
uj5u.com熱心網友回復:
這是我的 rules.json
[{
"id": 1,
"priority": 1,
"action": {
"type": "redirect",
"redirect": {
"transform": {
"queryTransform": {
"removeParams": ["postID"],
"addOrReplaceParams": [
{
"key": "po",
"value": how to gain postID's value 9028051665011570908
}
]
}
}
}
},
"condition": {
"urlFilter": "blogger.com/comment/frame",
"resourceTypes": ["main_frame"]
}
}]
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/528585.html
上一篇:chrome擴展background.js事件不運行
下一篇:Chrome錯誤“無法決議密文物件!”使用node.js的connect-mongo4.6.0來存盤Express會話資料
