我注入的content.js到这个URL https://www.cian.ru/cat.php?currency=2&deal_type=rent&engine_version=2&maxprice=51000&minprice=50000&offer_type=flat®ion=1&room1=1&room2=1&room3=1&room4=1&totime=-2&type=4 用的代码和在底部不能点击按钮(Сохранитьвфайл)。甚至我也无法用一些数据填写输入。
content.js
function clickFunction() {
console.log('here we are');
const input = '#geo-suggest-input'
const button = '#frontend-serp > div > div._93444fe79c-wrapper--1kKm_ > div > div > div > button:nth-child(1)'
const e1 = document.querySelectorAll(input)
e1[0].value = 'hello1'
const e2 = document.querySelector(button)
e2.click()
console.log('e1 = ', e1)
console.log('e2 = ', e2)
}
clickFunction()
manifest.json
{
"name": "File Downloader",
"version": "1.0",
"description": "Download files from cian.ru",
"permissions": [
"tabs",
"activeTab",
"declarativeContent",
"storage",
"<all_urls>"
],
"content_scripts": [{
"matches": ["*://*.www.cian.ru/*"],
"js": ["libs/jquery-v3.3.1.js", "content.js"],
"run_at": "document_end",
"all_frames": false
}],
"options_page": "options.html",
"background": {
"scripts": ["background.js"],
"persistent": false
},
"browser_action": {
"default_popup": "popup.html",
"default_icon": {
"16": "images/get_started16.png",
"32": "images/get_started32.png",
"48": "images/get_started48.png",
"128": "images/get_started128.png"
}
},
"icons": {
"16": "images/get_started16.png",
"32": "images/get_started32.png",
"48": "images/get_started48.png",
"128": "images/get_started128.png"
},
"manifest_version": 2
}
什么也没有发生。当我在英语最底部'СохранитьфайлвExcel的手动点击按钮(保存一个Excel文件),它会加载该文件。如果使用chrome扩展名,则不能。 那么谁知道是什么问题呢?