Send JavaScript codes to the browser easily

Discuss other useful utilities, general computing tips & tricks, Internet resources, etc.
WilburBr
Posts: 14
Joined: 22 Jun 2019, 22:17

Send JavaScript codes to the browser easily

22 Jun 2019, 22:57

Hello.

I searched extensively on how to submit javascript code to the browser. I tested imacros, kantu, katalon ... watched the videos of joe glines on selenium.

Then I discovered the addon called "Autofill", created by Tom Doan (http www.tohodo.com). available for firefox and chrome. Broken Link for safety

As it says at the beginning of the Overview "The Autofill extension serves one purpose: fill fields automatically on page load without any interaction from the user. This is its primary function, but it can do so much more.[...]"

The addon allows you to create multiple profiles with javascript codes and assign shortcut keys to them, which can be easily triggered by simple "send," shortcut key "" by autohotkey.


I was impressed by the ease of use and quality of the extension



https addons.mozilla.org /en/firefox/addon/autofill-quantum/ Broken Link for safety

https chrome.google.com /webstore/detail/autofill/nlmmgnhgdeffjkdckmikfpnddkbbfkkk Broken Link for safety
User avatar
Thoughtfu1Tux
Posts: 77
Joined: 31 May 2018, 23:26

Re: Send JavaScript codes to the browser easily

28 Jun 2019, 00:18

Cool! Thanks for sharing this. I’ve been having some issues automating a website with Selenium, hopefully this will help me overcome that problem.
WilburBr
Posts: 14
Joined: 22 Jun 2019, 22:17

Re: Send JavaScript codes to the browser easily

10 Jul 2019, 22:01

@Thoughtfu1Tux
:) it worked?
hallelujah98
Posts: 1
Joined: 01 Nov 2019, 12:30

Re: Send JavaScript codes to the browser easily

02 Nov 2019, 09:42

You can also use Tampermonkey and JavaScript to automate stuff in the browser. Using an app called Unified Remote on my phone I can launch Spotify on a server in my house. The code below connects Spotify on the phone and server. Great for adding custom key binds to websites or automating stuff you do regularly.

Code: Select all

// ==UserScript==
// @name         Spotify
// @require      https ajax.googleapis.com /ajax/libs/jquery/3.1.0/jquery.min.js  Broken Link for safety
// @namespace    http tampermonkey.net /  Broken Link for safety
// @version      0.1
// @description  try to take over the world!
// @author       You
// @include      https open.spotify.com*   Broken Link for safety
// @grant        none
// ==/UserScript==

// Your code here...
var spotInterval;
var $ = window.jQuery;
window.addEventListener("keydown", keysPressed, false);
window.addEventListener("keyup", keysReleased, false);

var keys = [];

function keysPressed(e) {
   // store an entry for every key pressed
    keys[e.keyCode] = true;

//        // Ctrl + shift+alt+q
   if (keys[17] && keys[18] && keys[16] && keys[81]) {
        //
       $('button.spoticon-devices-16').eq(0).trigger('click');

        // prevent default browser behavior

        e.preventDefault();
   }
}

function keysReleased(e) {
    // mark keys that were released
    keys[e.keyCode] = false;
}

function spotifyConnect(){
spotInterval = setInterval( function()
    {
        if ($('div.connect-device-list-item__info:contains("This Web Browser")').length>0){
        clearInterval(spotInterval);
        $('div.connect-device-list-item__info:contains("This Web Browser")').eq(0).trigger('click');
        }
    }, 2000);
}


$( document ).ready(function() {
 setTimeout(function() {
    // Your code here
    //5 seconds after page loads, click the menu item to select what device music is played back from
$('button.spoticon-devices-16').eq(0).trigger('click');
}, 5000);
//function to check every 2 seconds if device list exists - it won't exist unless Spotify is running on your phone
spotifyConnect();


});


Return to “Other Utilities & Resources”

Who is online

Users browsing this forum: No registered users and 2 guests