D
D
Dmitry Petrik2012-11-21 06:45:30
JavaScript
Dmitry Petrik, 2012-11-21 06:45:30

Userscripts in Chrome

I'm trying to learn user scripting. I am writing the simplest script with an alert. Alert should take off only when we go to the google site. The code:

// ==UserScript==
// @name           GA
// @description    Google alert
// @include          http://www.google.com/*
// @include          http://google.com/*
// @include          https://www.google.com/*
// @include          http://www.google.com/*
// @include          http://www.google.ru/*
// @include          http://google.ru/*
// @include          https://www.google.ru/*
// @include          http://www.google.ru/*
// ==/UserScript==
alert ("Привет, мир!");

I save this to my.user.js file and then drag and drop this file into Chrome extensions. The script is installed. And this alert starts popping up on all the sites that I visit. What am I doing wrong?
And how to see changes in your script in real time? Those. I edited the script and it immediately began to work differently. And so now I have to edit the script, remove the old extension from the browser, reinstall my edited script, only then the changes are applied.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nochkin, 2012-11-21
@Flexo

I could have forgotten something, but the user script must be installed via Greasemonkey, which just knows how to read these include . Otherwise, it reads like a regular script that starts executing right away.
You can also write www.google.tld/ * if you want to include all countries.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question