Inviter

facebook invite

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Inviter
// @namespace    http://codeot.com
// @version      0.1
// @description  facebook invite
// @author       Talha Habib
// @email        [email protected]
// @match        *://*.facebook.com/*
// ==/UserScript==

// -- start

function inviteAll(){
    console.log("firing");
    appendHTML(document.querySelector(".status_mt"),"<p>Firing inviter</p>");
for(var i=0; i<=document.querySelectorAll('._5i_q span ._42ft:not(._42fr):not(._59pe)').length;i++){
  setTimeout(Inviter,3000*i,i,document.querySelectorAll('._5i_q span ._42ft:not(._42fr):not(._59pe)').length);
 }
}
function Inviter(i,l){
     console.log("Invited "+ parseInt(i+1) +" Out of "+l);
     appendHTML(document.querySelector(".status_mt"),"<p>Invited "+ parseInt(i+1) +" Out of "+l+"</p>");
     if(parseInt(i+1)==l){
         console.log("Trigger new");
         appendHTML(document.querySelector(".status_mt"),"<p>Reached End of Block</p>");
         if(document.querySelectorAll("a[rel='async'].pam").length==1){
             loadMore();
             console.log("Got some more");
             appendHTML(document.querySelector(".status_mt"),"<p>Got some more</p>");
             setTimeout(inviteAll,5000);
         }else{
             console.log("--------------Closing-----------------");
             console.log("Invited all of them");
             appendHTML(document.querySelector(".status_mt"),"<p>Invited all of them</p>");
             appendHTML(document.querySelector(".status_mt"),"<p>Closing in 2 seconds</p>");
             setTimeout(function(){
                 document.querySelector(".status_mt").remove();
             },2000);
         }
     }else{
         if(document.querySelectorAll('._5i_q span ._42ft:not(._42fr):not(._59pe)').length>0){
             document.querySelectorAll('._5i_q span ._42ft:not(._42fr):not(._59pe)')[i].click();
         }else{
             console.log("Nothing to invite");
             appendHTML(document.querySelector(".status_mt"),"<p>Nothing to invite</p>");
             console.log("Checking more entries");
             appendHTML(document.querySelector(".status_mt"),"<p>Checking more entries</p>");
             if(document.querySelectorAll("a[rel='async'].pam").length==1){
                 console.log("Loading more");
                 appendHTML(document.querySelector(".status_mt"),"<p>Loading more...</p>");
                 loadMore();
                 setTimeout(inviteAll,5000);
             }else{
                 console.log("Nothing found");
                 appendHTML(document.querySelector(".status_mt"),"<p>Nothing found</p>");
                 return false;
             }
         }
     }
}
function loadMore(){
    document.querySelectorAll("a[rel='async'].pam")[0].click();
}
document.addEventListener ("keydown", function (zEvent) {
    if (zEvent.ctrlKey  &&  zEvent.altKey  &&  zEvent.code === "KeyG") {
       if(document.querySelectorAll(".status_mt").length==0){
         appendHTML(document.body,'<div class="status_mt" style="overflow:auto;position:absolute;top:0;left:0;width:300px;height:300px;background:white;z-index:99999;padding:10px"></div>');
       }
       appendHTML(document.querySelector(".status_mt"),"<p>Key Detected</p>");
       console.log("Key Detected");
       inviteAll();
    }
});

function appendHTML(element,html){
    var t = parseHTML(html);
    element.insertBefore(t, element.firstChild);
}
function parseHTML(html) {
    var t = document.createElement('template');
    t.innerHTML = html;
    return t.content.cloneNode(true);
}
// -- end