B
B
Baymaganbetov2017-08-20 13:59:04
SQLite
Baymaganbetov, 2017-08-20 13:59:04

Chrome extension how to get value from block div?

Good time and day.
Question from a newbie:
I'm writing an extension for Chrome. It is necessary that when the extension button is clicked, it receives data from the html page and displays it in alert
Sample page code

<div class="smallfont post-title">
<strong>Получить значение дива по class</strong>
</div>

This is the manifesto
{
    "manifest_version": 2,
    "name": "superpuper",
    "description": "yop yop",
    "version": "1.0",
    "browser_action": {
        "default_icon": "calc.png",
        "default_title": "yopyop"
    },

  "icons": { "16": "calc.png",
               "48": "calc.png",
               "128": "calc.png" },
  "permissions": [
    "tabs",
    "activeTab" 
   ],

  "background": {
    "scripts": ["background.js"]
  }
}

background.js
function onExtensionClick() {
var a = document.getElementsByClassName('post-title')[0].innerHTML;
alert("a");

Button does not work when pressed

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dimonchik, 2019-04-20
@dimonchik2013

give me your choice

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question