у меня есть расширение написанное на JS manifest { "manifestversion": 3, "name": "Info…
- User
у меня есть расширение написанное на JS
manifest { "manifest_version": 3, "name": "Info Extractor", "version": "1.0", "action": { "default_popup": "popup.html", "default_icon": "icons/icon128.png" }, "permissions": ["activeTab", "scripting"] }
popup.html
Нажми меня! Click Original Button Введите новое значение Обновить значение popup.js document.getElementById('fetchButton').addEventListener('click', () => { updateData(); });
document.getElementById('simulateButton').addEventListener('click', () => { chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => { chrome.scripting.executeScript({ target: { tabId: tabs[0].id }, func: () => { const button = document.querySelector('.by-button.by-builder-opr-btn.by-button--contained.by-button--xx-large.by-button--primary'); if (button) { button.click(); // Симулируем нажатие на кнопку } }, }); }); });
document.getElementById('updateValueButton').addEventListener('click', () => { const newValue = document.getElementById('newValue').value; chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => { chrome.scripting.executeScript({ target: { tabId: tabs[0].id }, func: (value) => { const element = document.querySelector('.pb-position-editor.pb-position-editor-qty-containner'); if (element) { element.innerText = value; // Обновляем текст элемента } }, args: [newValue] // Передаем новое значение }); }); });
function updateData() { chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => { chrome.scripting.executeScript({ target: { tabId: tabs[0].id }, func: () => { let data = []; document.querySelectorAll('.by-table-row').forEach((row) => { const cells = row.querySelectorAll('.by-table-cell'); let rowData = { modeledPositions: cells[0] ? cells[0].innerText : '--', leverage: cells[1] ? cells[1].innerText : '--', expiration: cells[2] ? cells[2].innerText : '--', strikePrice: cells[3] ? cells[3].innerText : '--', type: cells[4] ? cells[4].innerText : '--', direction: cells[5] ? cells[5].innerText : '--', bidSize: cells[6] ? cells[6].innerText : '--', bidPriceIV: cells[7] ? cells[7].innerText : '--', orderPriceIV: cells[8] ? cells[8].innerText : '--', quantity: cells[9] ? cells[9].innerText : '--', askSize: cells[10] ? cells[10].innerText : '--', askPriceIV: cells[11] ? cells[11].innerText : '--', pnl: cells[12] ? cells[12].innerText : '--', delta: cells[13] ? cells[13].innerText : '--', gamma: cells[14] ? cells[14].innerText : '--', vega: cells[15] ? cells[15].innerText : '--', theta: cells[16] ? cells[16].innerText : '--', action: cells[17] ? cells[17].innerText : '--' };
// Логика для обновления "Цены ордера" в зависимости от "Направления" const orderPriceCell = cells[8]; if (rowData.direction === 'Купить' && cells[11]) { orderPriceCell.innerText = cells[11].innerText; // Ставим "Цену предложения" } else if (rowData.direction === 'Продать' && cells[7]) { orderPriceCell.innerText = cells[7].innerText; // Ставим "Цену спроса" }
data.push(rowData); }); return data; }, }, (results) => { if (results && results[0]) { let data = results[0].result; let dataDiv = document.getElementById('data');
- Assistant
- User
напиши полный код который я должен написать
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.