Run javascript on my Chrome extension

Asked

Viewed 631 times

1

Speak guys! I work most of the time filling web Formularios, and often caught about 50-100 pages with the same data... So I have to manually fill out one by one. I came up with the idea to create an extension in Chrome that allows me to fill out these forms with 1 click only. But I also need to run the following javascript:

javascript: resRecebimentoSelecionado('1', 'Fulano de Souza', 'Gerente');

Currently my extension is

var data = document.getElementById("txtDataRecebimento");
data.value = "20/06/2018";

var motorista = document.getElementById("txtTransportadorNomeMotorista");
motorista.value = "Fulano";

var placa = document.getElementById("txtTransportadorPlacaVeiculo");
placa.value = "LLLXXX";

var obs = document.getElementById("txtObservacoes");
obs.value = "N/C";

Does anyone have any idea how I do to run this Javascript?

  • I use some automations by simply adding a javascript code as a favorite in the bookmark bar. Creating a new bookmark page and putting the code on the link, example: javascript: var ok="Hello"; Alert(ok); The problem is that you need to format the whole code in a row and it is bad for maintenance,

1 answer

0

I use some automations simply by adding a javascript code as a favorite in the bookmark bar.

Creating a new bookmark page and placing the code in the URL field.

Example:

javascript: var ok="Ola"; alert(ok); 

To use just click on the created favorite it will execute the code on any page you are.

The only problem is that you need to format the whole code in a row and it is bad for maintenance.

  • Exactly... It gets really bad! The intention to create the extension in Chrome was precisely the ease to edit just by file . JS, and who knows a future increment can make the changes by the browser itself. Is there no way to run this function by the extension itself? Any commands that at least input this JS into the Chrome console

  • Friend I’m trying to do the same thing as Voce, I came to create a cute "interface" and a "Fill Form" option and when I click I would execute a code I developed for the forms here in the company.However I stumbled on the Google security policy I read the documentation I am very close to getting.

  • From this link: https://developers.google.com/web/fundamentals/security/csp/? hl=en

Browser other questions tagged

You are not signed in. Login or sign up in order to post.