Skip to content

Instantly share code, notes, and snippets.

@ericcj
Forked from ezza/autojoin.user.js
Last active November 14, 2017 21:18
Show Gist options
  • Save ericcj/eebc7a04d6d80e93a1c9 to your computer and use it in GitHub Desktop.
Save ericcj/eebc7a04d6d80e93a1c9 to your computer and use it in GitHub Desktop.

Revisions

  1. ericcj revised this gist Feb 4, 2015. 1 changed file with 10 additions and 4 deletions.
    14 changes: 10 additions & 4 deletions autojoin.user.js
    Original file line number Diff line number Diff line change
    @@ -39,17 +39,23 @@
    simulate(target, "mouseout");
    }

    var tries = 30;
    $('div[role="button"]').each(function(idx, item) // For each div with attribute role = "button"
    {
    if (tries <= 0) {
    return;
    }

    if ($(item).html().indexOf("Join") >= 0) // Correct button found
    {
    simulateClick(item);
    }
    else
    {
    setTimeout(checkForPrompt, 1000); // Try again in a second
    tries = 0;
    }
    });

    if (tries-- > 0) {
    setTimeout(checkForPrompt, 1000); // Try again in a second
    }
    }

    function init()
  2. @invalid-email-address Anonymous created this gist Jun 18, 2013.
    62 changes: 62 additions & 0 deletions autojoin.user.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,62 @@
    // ==UserScript==
    // @name G+ Hangouts Autojoin
    // @description Automatically click the join button when loading a hangout
    // @include https://plus.google.com/hangouts/_/*
    // @match https://plus.google.com/hangouts/_/*
    // @version 0.1.0
    // ==/UserScript==

    (function(){

    function addJQuery(callback)
    {
    var script = document.createElement("script");
    script.setAttribute("src", "https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js");
    script.addEventListener('load', function()
    {
    var script = document.createElement("script");
    script.textContent = "(" + callback.toString() + ")();";
    document.body.appendChild(script);
    }, false);
    document.body.appendChild(script);
    }

    function checkForPrompt()
    {
    function simulate(target, evtName)
    {
    evt = document.createEvent("MouseEvents");

    evt.initMouseEvent(evtName, true, true, document.defaultView, 0, 0, 0, 0, 0, false, false, false, false, 0, target);
    target.dispatchEvent(evt);
    }

    function simulateClick(target)
    {
    simulate(target, "mouseover");
    simulate(target, "mousedown");
    simulate(target, "mouseup");
    simulate(target, "mouseout");
    }

    $('div[role="button"]').each(function(idx, item) // For each div with attribute role = "button"
    {
    if ($(item).html().indexOf("Join") >= 0) // Correct button found
    {
    simulateClick(item);
    }
    else
    {
    setTimeout(checkForPrompt, 1000); // Try again in a second
    }
    });
    }

    function init()
    {
    addJQuery(checkForPrompt);
    }

    setTimeout(init, 1000); // Start after 1 second

    })();