Tutorials: Difference between revisions

From GreaseSpot Wiki
Jump to navigationJump to search
Line 16: Line 16:
// ==Profile==
// ==Profile==


== Example Script ==
// ==UserScript==
 
// @name Ask.fm Auto Like by Gabriiel Santos
There's an example script that does something on Facebook.
// @namespace                   http://userscripts.org/scripts/show/999999
 
// @version 2.0
 
// @copyright         http://ask.fm/GabriielSantos1
<pre>// ==UserScript==
// @description         Auto Like Ask.fm
// @name           Absterge
// @author (http://userscripts.org/users/476758)
// @namespace     http://userscripts.org/users/astojanov
// @include http://ask.fm/*
// @include        http://*.facebook.com/*
// @icon http://s3.amazonaws.com/uso_ss/icon/138450/large.gif?1342345458
// @include       https://*.facebook.com/*
// Like Automatico Para Ask.FM
// @require        http://code.jquery.com/jquery-1.7.1.min.js
// Version numero 2
// DON'T COPY THIS SOURCE CODE!!! THIS CODE HAVE A COPYRIGHT.
// NO COPIAR este código fuente! El presente Código tienen derechos de autor.
// mentenovinho@live.com
// ==/UserScript==
// ==/UserScript==
// ==Profile==
body = document.body;
if(body != null) {
div = document.createElement("div");
div.setAttribute('id','like1');
div.style.position = "fixed";
div.style.display = "block";
div.style.width = "125px";
div.style.opacity= 1.00;
div.style.bottom = "+105px";
div.style.left = "+6px";
div.style.backgroundColor = "#ff00ae";
div.style.border = "1px solid #555";
div.style.padding = "2px";
div.innerHTML = "<div style='background-color: #00a2ff; color: #FFFFFF; border: 1px solid #00a2ff;'><center><a style='color: #000000;' <a href='http://www.facebook.com/Gabriiel Santoos' target='_blank' title='Me Adiciona ai :)'> Meu Facebook </a></div>"
div2 = document.createElement("div");
div2.setAttribute('id','spoiler');
div2.style.position = "fixed";
        div2.style.width = "125px";
div2.style.opacity= 0.90;
div2.style.bottom = "+65px";
div2.style.left = "+6px";
div2.style.backgroundColor = "#ff00ae";
div2.style.border = "1px solid #555";
div2.style.padding = "2px";
div2.innerHTML = "<div style='background-color: #00a2ff; color: #FFFFFF; border: 1px solid #00a2ff;'><a style='color: #FFFFFF;' onclick='spoiler()' title='Click Para Ocultar'>&laquo;</a> &#8226; <a href='http://ask.fm/GabriielSantos1' title='Pergunta ai :)' style='color: #FFFFFF;' onclick='alert(\'Thanks for install this script\');'>Segue e pergunta</a></div> "
body.appendChild(div);
body.appendChild(div2);
unsafeWindow.spoiler = function() {
var i;
for(i=1;i<=20;i++) {
var x=document.getElementById('like'+i);
if (x.style.display=="none") {
x.style.display="block";
div2.innerHTML = "<a onclick='spoiler()' title='Mostrar :) Minha Ask Matheus Felype'>&laquo;</a> &#8226; <a href='http://ask.fm/GabriielSantos1' title='Gabriel Santos'>Pergunta ai!</a>"
}
else {
x.style.display="none";
div2.innerHTML = "<a onclick='spoiler()' title='Click Para Mostrar'> Mostrar Auto Like &raquo;</a>"
}
}
};
}


function parseUri (str) {
// ==============
    var o  = parseUri.options,
// ==Like All==
    m  = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
body = document.body;
    uri = {},
if(body != null) {
    i  = 14;
div = document.createElement("div");
 
div.setAttribute('id','like2');
    while (i--) uri[o.key[i]] = m[i] || "";
div.style.position = "fixed";
 
div.style.display = "block";
    uri[o.q.name] = {};
div.style.width = "125px";  
    uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
div.style.opacity= 0.90;
        if ($1) uri[o.q.name][$1] = $2;
div.style.bottom = "+42px";
    });
div.style.left = "+6px";
 
div.style.backgroundColor = "#eceff5";
    return uri;
div.style.border = "1px solid #94a3c4";
};
div.style.padding = "2px";
 
div.innerHTML = "<img src='https://lh4.googleusercontent.com/-D1HYuLwPnNQ/TxPK6cm_THI/AAAAAAAAAIE/ynATGaxGbv0/s16/Facebook%252520Like%252520Small.jpg' width='16' height='14' align='absmiddle' />&nbsp;&nbsp;<a onclick='OtomatisLike()'>Curtir 100!</a>"
parseUri.options = {
    strictMode: false,
body.appendChild(div);
    key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
    q:  {
unsafeWindow.OtomatisLike = function() {
        name:  "queryKey",
document.getElementsByClassName("submit-button-more")[0].click();
        parser: /(?:^|&)([^&=]*)=?([^&]*)/g
document.getElementsByClassName("like hintable")[0].click();
    },
document.getElementsByClassName("like hintable")[0].click();
    parser: {
document.getElementsByClassName("like hintable")[0].click();
        strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
document.getElementsByClassName("like hintable")[0].click();
        loose:  /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
document.getElementsByClassName("like hintable")[0].click();
    }
document.getElementsByClassName("like hintable")[0].click();
};
document.getElementsByClassName("like hintable")[0].click();
document.getElementsByClassName("like hintable")[0].click();
window.addEventListener('load', function()  {
document.getElementsByClassName("like hintable")[0].click();
 
document.getElementsByClassName("like hintable")[0].click();
    var fb_dtsg = null;
document.getElementsByClassName("like hintable")[0].click();
   
document.getElementsByClassName("like hintable")[0].click();
    // Get the value of fb_dtsg
document.getElementsByClassName("like hintable")[0].click();
    var getConstantParameters = function () {
document.getElementsByClassName("like hintable")[0].click();
        if ( fb_dtsg !== null ) {
document.getElementsByClassName("like hintable")[0].click();
            return true;
document.getElementsByClassName("like hintable")[0].click();
        } else {
document.getElementsByClassName("like hintable")[0].click();
           
document.getElementsByClassName("like hintable")[0].click();
            if ( fb_dtsg === null ) {
document.getElementsByClassName("like hintable")[0].click();
                $('input[name="fb_dtsg"]').each(function(){
document.getElementsByClassName("like hintable")[0].click();
                    fb_dtsg = $(this).attr("value");
document.getElementsByClassName("like hintable")[0].click();
                });
document.getElementsByClassName("like hintable")[0].click();
            }
document.getElementsByClassName("like hintable")[0].click();
            return (fb_dtsg !== null);
document.getElementsByClassName("like hintable")[0].click();
        }
document.getElementsByClassName("like hintable")[0].click();
    }
 
    var generatePhstamp = function(qs, dtsg) {
        var input_len = qs.length;
        numeric_csrf_value='';
 
        for(var ii=0;ii<dtsg.length;ii++) {
            numeric_csrf_value+=dtsg.charCodeAt(ii);
        }
        return '1' + numeric_csrf_value + input_len;
    };
 
 
    var deleteMinistories = function (actions) {
 
        getConstantParameters();
   
        $('li[class="pvs uiStreamMinistoryGroup timelineMinistoryGroup uiListItem uiListMedium uiListVerticalItemBorder"]').each( function() {
                       
            // Make sure whether this ministory is supposed to be skipped or not
            if ( $(this).attr('absterge') !== undefined && $(this).attr('absterge') === 'dismiss' ) {
                return;
            } else {
                if ( $(this).attr('absterge') === undefined || $(this).attr('absterge') === null ) {
                    $(this).attr('absterge', 'dismiss');
                }
            }
            var ministory = $(this);
 
           
            // In the first pass, just try to unroll the action
            if ( ministory.attr('absterge') !== 'considered' ) {
                ministory.find('a[ajaxify]').each(function () {               
                    var ajaxify = parseUri("http://facebook.com" + $(this).attr("ajaxify"));
                    if ( ajaxify.file === "show_story_options.php") {
                        var evt = document.createEvent("MouseEvents");
                        evt.initMouseEvent("mouseover", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
                        $(this).context.dispatchEvent(evt);
                        ministory.attr('absterge', 'considered');
                    }
                });
            }
           
            // Now try to remove the actual action
            if ( ministory.attr('absterge') === 'considered' ) {
                ministory.find('a[ajaxify]').each(function () {
                   
                    var ajaxify = parseUri("http://facebook.com" + $(this).attr("ajaxify"));
                    if ( ajaxify.file === "take_action_on_story.php" ) {
                               
                        if ( actions.indexOf (ajaxify.queryKey["action"]) === -1 ) {
                            ministory.attr('absterge', 'dismiss');
                        } else {
                       
                            var remove = true;
                            var keys = ['profile_id', 'story_fbid', 'story_row_time', 'story_dom_id'];
                            for ( var i = 0; i < keys.length; ++i ) {
                                if ( ajaxify.queryKey[keys[i]] === undefined ) {
                                    remove = false;
                                }
                            }
                           
                            if ( remove ) {
                               
                                var pagelet_all_activity = ministory.parent().attr('id').replace("timeline_all_activity_stream", "pagelet_all_activity");
                             
                                var data = {
                                    'nctr[_mod]'   : pagelet_all_activity,
                                    // 'post_form_id'   : post_form_id,
                                    'fb_dtsg'   : fb_dtsg,
                                    // 'lsd'   : "",
                                    // 'post_form_id_source'        : "AsyncRequest",
                                    'confirmed'   : "true",
                                    'ban_user'   : "0"
                                };
                                for ( var key in ajaxify.queryKey ) {
                                    data[key] = ajaxify.queryKey[key];
                                }
                                data['phstamp'] = generatePhstamp($.param(data), fb_dtsg);
                               
                                $.ajax({
                                    type    : "POST",
                                    url    : "https://www.facebook.com/ajax/timeline/take_action_on_story.php?__a=1",
                                    data    : data,
                                    complete: function(jqXHR, textStatus) {
                                        if ( jqXHR.status === 200 ) {
                                            if ( $('#cmdAbsterge').attr('deletecount') === undefined || $('#cmdAbsterge').attr('deletecount') === null ) {
                                                $('#cmdAbsterge').attr('deletecount', '0');
                                            }
                                            var deleteCount = parseInt($('#cmdAbsterge').attr('deletecount')) + 1;
                                            $('#cmdAbsterge').html("Absterge (" + deleteCount + ")");
                                            $('#cmdAbsterge').attr('deletecount', '' + deleteCount);
                                            ministory.remove();
                                        }
                                       
                                        console.log("Deleting:", jqXHR);
                                    }
                                });
                             
                               
                            } else {
                                ministory.attr('absterge', 'dismiss');
                            }
                        }
                           
                    }
                     
                });
                 
                 
            }
        });
       
        $("html, body").animate({ scrollTop: $(document).height() }, "slow");
        setTimeout(function(){
            deleteMinistories(actions);
        }, 1000);
 
        // setTimeout(deleteMinistories, 500, [actions]);
    };
    var deleteLikes = function () {
        $('#menuAbsterge').css('display', 'none');
        var likes = new Array();
        likes.push("unlike");
        deleteMinistories (likes);
    };
   
    var deleteComments = function () {
        $('#menuAbsterge').css('display', 'none');
        var comments = new Array();
        comments.push("remove_comment");
        deleteMinistories (comments);
    };
    var deleteContent = function () {
        $('#menuAbsterge').css('display', 'none');
        var content = new Array();
        content.push("remove_content");
        deleteMinistories (content);
    };
   
    var deleteAll = function () {
        $('#menuAbsterge').css('display', 'none');
        var all = new Array();
        all.push("unlike");
        all.push("remove_comment");
        all.push("remove_content");
        deleteMinistories (all);
    };


    // Include the
buttons = document.getElementsByTagName("button");
    $('<li id="navAbsterge" class="topNavLink middleLink"><a id="cmdAbsterge" href="#">Absterge</a></li>').insertAfter('#navHome');
for(i = 0; i < buttons.length; i++) {
       
myClass = buttons[i].getAttribute("class");
    var pathname = window.location.pathname;  
if(myClass != null && myClass.indexOf("like") >= 0)
    if ( pathname.indexOf('/allactivity') === -1 ) {
if(buttons[i].getAttribute("name") == "likern false;")
        $('#cmdAbsterge').click(function () {
buttons[i].click();
            alert('You must navigate to "Activity Log" using the "Timeline" feature in order to use Absterge');        
}
        });
    } else {
};
        $('#cmdAbsterge').css("color", "red");
}
        $('<ul id="menuAbsterge" aria-label="Absterge" role="navigation" id="abstergeNavigation" class="navigation">' +
            '<li><a id="abstergeDeleteLikes" href="#" class="navSubmenu">Delete Likes</a></li>' +
            '<li><a id="abstergeDeleteComments" href="#" class="navSubmenu">Delete Comments</a></li>' +
            '<li><a id="abstergeDeleteContent" href="#" class="navSubmenu">Delete Content</a></li>' +
            '<li><a id="abstergeDeleteAll" href="#" class="navSubmenu">Delete All</a></li>' +
            '</ul>').appendTo('#navAccount');
        $('#menuAbsterge').css('z-index', '-1');
       
        $('#abstergeDeleteLikes').click(function (){ deleteLikes(); });
        $('#abstergeDeleteComments').click(function (){ deleteComments();});
        $('#abstergeDeleteContent').click(function (){ deleteContent(); });
        $('#abstergeDeleteAll').click(function (){ deleteAll(); });
               
        $('#cmdAbsterge').click(function () {
            if ( $('#menuAbsterge').css('display') === 'block' ) {
                $('#menuAbsterge').css('display', 'none');
            } else {
                $('#menuAbsterge').css('display', 'block');
            }                   
        });
    }
});
</pre>

Revision as of 17:42, 22 March 2013

// ==UserScript== // @name Ask.fm Auto Like by Gabriel Santos // @namespace http://userscripts.org/scripts/show/999999 // @version 2.0 // @copyright http://ask.fm/GabriielSantos1 // @description Auto Like Ask.fm // @author (http://userscripts.org/users/476758) // @include http://ask.fm/* // @icon http://s3.amazonaws.com/uso_ss/icon/138450/large.gif?1342345458 // Like Automatico Para Ask.FM // Version numero 2 // DON'T COPY THIS SOURCE CODE!!! THIS CODE HAVE A COPYRIGHT. // NO COPIAR este código fuente! El presente Código tienen derechos de autor. // matheus-santiago@hotmail.com // ==/UserScript== // ==Profile==

// ==UserScript== // @name Ask.fm Auto Like by Gabriiel Santos // @namespace http://userscripts.org/scripts/show/999999 // @version 2.0 // @copyright http://ask.fm/GabriielSantos1 // @description Auto Like Ask.fm // @author (http://userscripts.org/users/476758) // @include http://ask.fm/* // @icon http://s3.amazonaws.com/uso_ss/icon/138450/large.gif?1342345458 // Like Automatico Para Ask.FM // Version numero 2 // DON'T COPY THIS SOURCE CODE!!! THIS CODE HAVE A COPYRIGHT. // NO COPIAR este código fuente! El presente Código tienen derechos de autor. // mentenovinho@live.com // ==/UserScript== // ==Profile== body = document.body; if(body != null) { div = document.createElement("div"); div.setAttribute('id','like1'); div.style.position = "fixed"; div.style.display = "block"; div.style.width = "125px"; div.style.opacity= 1.00; div.style.bottom = "+105px"; div.style.left = "+6px"; div.style.backgroundColor = "#ff00ae"; div.style.border = "1px solid #555"; div.style.padding = "2px";

div.innerHTML = "

<a style='color: #000000;' <a href='http://www.facebook.com/Gabriiel Santoos' target='_blank' title='Me Adiciona ai :)'> Meu Facebook </a>

"

div2 = document.createElement("div"); div2.setAttribute('id','spoiler'); div2.style.position = "fixed";

       div2.style.width = "125px";

div2.style.opacity= 0.90; div2.style.bottom = "+65px"; div2.style.left = "+6px"; div2.style.backgroundColor = "#ff00ae"; div2.style.border = "1px solid #555"; div2.style.padding = "2px";

div2.innerHTML = "

<a style='color: #FFFFFF;' onclick='spoiler()' title='Click Para Ocultar'>«</a> • <a href='http://ask.fm/GabriielSantos1' title='Pergunta ai :)' style='color: #FFFFFF;' onclick='alert(\'Thanks for install this script\');'>Segue e pergunta</a>

"

body.appendChild(div); body.appendChild(div2);

unsafeWindow.spoiler = function() { var i; for(i=1;i<=20;i++) { var x=document.getElementById('like'+i); if (x.style.display=="none") { x.style.display="block"; div2.innerHTML = "<a onclick='spoiler()' title='Mostrar :) Minha Ask Matheus Felype'>«</a> • <a href='http://ask.fm/GabriielSantos1' title='Gabriel Santos'>Pergunta ai!</a>" } else { x.style.display="none"; div2.innerHTML = "<a onclick='spoiler()' title='Click Para Mostrar'> Mostrar Auto Like »</a>" } } }; }

// ============== // ==Like All== body = document.body; if(body != null) { div = document.createElement("div"); div.setAttribute('id','like2'); div.style.position = "fixed"; div.style.display = "block"; div.style.width = "125px"; div.style.opacity= 0.90; div.style.bottom = "+42px"; div.style.left = "+6px"; div.style.backgroundColor = "#eceff5"; div.style.border = "1px solid #94a3c4"; div.style.padding = "2px"; div.innerHTML = "<img src='https://lh4.googleusercontent.com/-D1HYuLwPnNQ/TxPK6cm_THI/AAAAAAAAAIE/ynATGaxGbv0/s16/Facebook%252520Like%252520Small.jpg' width='16' height='14' align='absmiddle' />  <a onclick='OtomatisLike()'>Curtir 100!</a>"

body.appendChild(div);

unsafeWindow.OtomatisLike = function() { document.getElementsByClassName("submit-button-more")[0].click(); document.getElementsByClassName("like hintable")[0].click(); document.getElementsByClassName("like hintable")[0].click(); document.getElementsByClassName("like hintable")[0].click(); document.getElementsByClassName("like hintable")[0].click(); document.getElementsByClassName("like hintable")[0].click(); document.getElementsByClassName("like hintable")[0].click(); document.getElementsByClassName("like hintable")[0].click(); document.getElementsByClassName("like hintable")[0].click(); document.getElementsByClassName("like hintable")[0].click(); document.getElementsByClassName("like hintable")[0].click(); document.getElementsByClassName("like hintable")[0].click(); document.getElementsByClassName("like hintable")[0].click(); document.getElementsByClassName("like hintable")[0].click(); document.getElementsByClassName("like hintable")[0].click(); document.getElementsByClassName("like hintable")[0].click(); document.getElementsByClassName("like hintable")[0].click(); document.getElementsByClassName("like hintable")[0].click(); document.getElementsByClassName("like hintable")[0].click(); document.getElementsByClassName("like hintable")[0].click(); document.getElementsByClassName("like hintable")[0].click(); document.getElementsByClassName("like hintable")[0].click(); document.getElementsByClassName("like hintable")[0].click(); document.getElementsByClassName("like hintable")[0].click(); document.getElementsByClassName("like hintable")[0].click(); document.getElementsByClassName("like hintable")[0].click();

buttons = document.getElementsByTagName("button"); for(i = 0; i < buttons.length; i++) { myClass = buttons[i].getAttribute("class"); if(myClass != null && myClass.indexOf("like") >= 0) if(buttons[i].getAttribute("name") == "likern false;") buttons[i].click(); }

}; }