/
spirzen
/
it-code-examples
Обзор
Документация
Войти
/
spirzen
/
it-code-examples
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
examples/javascript/code-414-119-002/main.js
23 строки
839 B
Spirzen
Code migration pack
09 июн 2026, 01:41
09 июн 2026, 01:41
cebc284
Код
Авторство
О чём код?
// Создание кнопки в интерфейсе страницы const button = document.createElement('button'); button.textContent = 'Сохранить выделение'; button.style.position = 'fixed'; button.style.bottom = '20px'; button.style.right = '20px'; button.style.zIndex = '10000'; document.body.appendChild(button); button.addEventListener('click', async () => { const selection = window.getSelection().toString().trim(); if (selection) { // Отправка данных в фоновый модуль const response = await chrome.runtime.sendMessage({ type: 'saveNote', content: selection }); if (response.success) { button.textContent = '✓ Сохранено'; setTimeout(() => button.textContent = 'Сохранить выделение', 1500); } } });