working on it ...

Filters

Explore Public Snippets

Sort by

Found 116k snippets

    public by szmerek modified Sep 6, 2017  172  2  4  0

    OnClick without setting an attribute of the link

    //<div id="dog" >Woow woow</div>
    
    
        (function() {
            document.getElementById("dog").onclick = function() { 
                alert('fuf fuf'); 
            };
        })();																								

    public by tttttttttt modified Aug 30, 2017  34  1  1  0

    ttttttttttttttttt

    tttt
    // ==UserScript==
    // @name         MicroScatter Cheater Script
    // @namespace    http://qsysmine.tk/
    // @version      0.1
    // @description  Press C on microscatter to win
    // @author       qsysmine
    // @match        https://quizlet.com/*/microscatter
    // @grant        none
    // ==/UserScript==
    
    (function() {
        var $ = window.jQuery;
        var cheat = function() {
            var ids = [];
            var checkhasid = function(id) {
                for(var i in ids) {
                    if(ids[i] == id) {
                        return true;
                    }
                }
                return false;
            };
            $('.cell').each(function(index){
    
                if(checkhasid($(this).attr("data-id"))) $('[data-id="' + $(this).attr("data-id") + '"]').trigger("click")
                if(!checkhasid($(this).attr("data-id"))) ids.push($(this).attr("data-id"));
    
            });
        };
        var z = 0;
        $('*').keyup(function(e) {
            if(e.keyCode == 67 && z == 0) {z = 1; cheat();}
        });
    })();
    
    

    public by tttttttttt modified Aug 30, 2017  30  0  1  0

    ttttttttttt

    ttttttttttttttt
    // ==UserScript==
    // @name         MicroScatter Cheater Script
    // @namespace    http://qsysmine.tk/
    // @version      0.1
    // @description  Press C on microscatter to win
    // @author       qsysmine
    // @match        https://quizlet.com/*/microscatter
    // @grant        none
    // ==/UserScript==
    
    (function() {
        var $ = window.jQuery;
        var cheat = function() {
            var ids = [];
            var checkhasid = function(id) {
                for(var i in ids) {
                    if(ids[i] == id) {
                        return true;
                    }
                }
                return false;
            };
            $('.cell').each(function(index){
    
                if(checkhasid($(this).attr("data-id"))) $('[data-id="' + $(this).attr("data-id") + '"]').trigger("click")
                if(!checkhasid($(this).attr("data-id"))) ids.push($(this).attr("data-id"));
    
            });
        };
        var z = 0;
        $('*').keyup(function(e) {
            if(e.keyCode == 67 && z === 0) {z = 1; cheat();}
        });
    })();
    
    

    public by szmerek modified Aug 20, 2017  82  0  2  0

    Remove part of a string before specified character

    //remove string before '&' if want to include character '&' then 'indexOf("&") + 0'
    var str = "black&white";
    str = str.substring(str.indexOf("&") + 1);
    
    //or use regex
    var str = "black&white";
    str = /&(.+)/.exec(str)[1];
    
    // or use .split() and .pop() 
    var str = "black&white";
    str = str.split("&").pop();						

    public by szmerek modified Aug 20, 2017  78  1  2  0

    Check whether a string matches a regex

    //RegExp allows to inject variable values into the regex string
    var str = "sample1";
    var re = new RegExp("^([a-z0-9]{5,})$");
    if (re.test(str)) {
        console.log("valid");
    } else {
        console.log("invalid");
    }					

    public by szmerek modified Aug 20, 2017  89  0  3  0

    Hide element(s) by class

    Some examples for hiding the class.
    //Ex 
    //<div class="appBanner">appbanner</div> 
    
    document.getElementsByClassName('appBanner')[0].style.visibility = 'hidden';
    
    //change the style rules of all elements matching the class
    
    [].forEach.call(document.querySelectorAll('.appBanner'), function (el) {
      el.style.visibility = 'hidden';
    });
    
    //If for...of is available then use
    
    for (let el of document.querySelectorAll('.appBanner')) el.style.visibility = 'hidden';
    
    //And the other one
    
    Array.filter( document.getElementsByClassName('appBanner'), function(elem){ elem.style.visibility = 'hidden'; });
    
    //and the last one
    
    var appBanners = document.getElementsByClassName('appBanner'), i;
    
    for (i = 0; i < appBanners.length; i += 1) {
        appBanners[i].style.display = 'none';
    }																								

    public by sunole modified Aug 5, 2017  62  0  1  0

    test javascript one

    // Enter here the actual content of the snippet.			
    var aaaa =5;

    public by ElectroSoft modified Jul 15, 2017  124  0  4  0

    Prueba de Ajax

    Prueba de Axaj en javascript nativo.
    function ajax()
    {
        var elements = document.getElementsByClassName("formVal");
        var formData = new FormData(); 
        for(var i=0; i<elements.length; i++)
        {
            formData.append(elements[i].name, elements[i].value);
        }
        var xmlHttp = new XMLHttpRequest();
            xmlHttp.onreadystatechange = function()
            {
                if(xmlHttp.readyState == 4 && xmlHttp.status == 200)
                {
                    alert(xmlHttp.responseText);
                }
            }
            xmlHttp.open("post", "prueba.php"); 
            xmlHttp.send(formData); 
    }

    public by slavka1979 modified May 26, 2017  165  1  4  0

    Promise.all for Rejections and Resolves

    Always call then, even when one promise rejects
    // https://davidwalsh.name/promises-results
    Promise.all([
        // Resolves
        Promise.resolve(1), 
        // Rejects after 2 seconds
        new Promise((resolve, reject) => setTimeout(() => reject(1), 2000))
    ].map(p => p.catch(() => undefined))).then(() => console.log('done!'));

    public by vladimirov1 modified May 18, 2017  79  0  1  0

    print crosfilter results in console

    print crosfilter results in console: print_filter.js
    /**
     * Created by user on 18/05/17.
     */
    			// Super useful for debug in web console
    			function print_filter(filter){
    				var f=eval(filter);
    				if (typeof(f.length) != "undefined") {}else{}
    				if (typeof(f.top) != "undefined") {f=f.top(Infinity);}else{}
    				if (typeof(f.dimension) != "undefined") {f=f.dimension(function(d) { return "";}).top(Infinity);}else{}
    				console.log("DC DEBUG: "+filter+"("+f.length+") = "+JSON.stringify(f).replace("[","[\n\t").replace(/}\,/g,"},\n\t").replace("]","\n]"));
    			}
    
    
    • Public Snippets
    • Channels Snippets