Skip to content

Instantly share code, notes, and snippets.

/*--- waitForKeyElements(): A utility function, for Greasemonkey scripts,
that detects and handles AJAXed content.
Usage example:
waitForKeyElements (
"div.comments"
, commentCallbackFunction
);
@tegomass
tegomass / waitForGmail.js
Last active February 11, 2017 21:40
WaitForGmail loading -- The jQuery ready function doesn't work on AJAX call, use this instead -- Use this link to embed : https://gist.githubusercontent.com/tegomass/734b5a868f9222a6c1a89a42232768b5/raw/
/*
usage example: waitForGmail(function(){ console.log('TEGO!!')});
*/
function waitForGmail(callback){
if (window.top != window.self) //don't run on frames or iframes
return;
var zGbl_PageChangedByAJAX_Timer = '';
@tegomass
tegomass / greasemonkey_header.js
Last active February 11, 2017 21:50
Simple header for GreaseMonkey Script
// ==UserScript==
// @name GM_name
// @namespace https://gist.github.com/tegomass
// @description GM_description
// @include https://mail.google.com/*
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js
// @exclude %exclude%
// @version 1
// @grant GM_addStyle
// ==/UserScript==
@tegomass
tegomass / leboncoin_rss.user.js
Last active February 22, 2017 08:30
Greasemonkey script for LeBonCoin - A kind of RSS for the website Le bon coin with your query -- each time you reload a page, a GET request is sent to lbc and match your query. If a new offer is available, the link is shown on the top of the page.
// ==UserScript==
// @name Leboncoin RSS
// @namespace http://gist.github.com/tegomass/18866de2d73399136151cd1e7ea8e8b4
// @author Tegomass
// @description A kind of RSS for LeBonCoin with your personnal search
// @include *
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js
// @version 1.4
// @updateURL https://gist.githubusercontent.com/tegomass/18866de2d73399136151cd1e7ea8e8b4/raw
// @grant GM_addStyle
@tegomass
tegomass / Convert CURL to JSON string
Last active March 2, 2017 12:54
Convert Firebug multipart/form-data key/value pair in JSON string
1) On firebug, navigate to the request.
2) Right-click on the content then select "Copy for CURL"
3) Paste the clipboard to a text editor (e.g. Sublime Text 2)
4) Use the function Search&Replace Regex with the following patterns :
Find : .*?form-data; name=(".+?").*?\\r\\n\\r\\n(.*?)\\r\\n-.*?
Replace with : \1:"\2",\n
@tegomass
tegomass / gm_xhr.js
Last active October 28, 2017 08:28
GM_XHR - jQuery greasemonkey - Allow CORS with local $AJAX request
// allows using all Jquery AJAX methods in Greasemonkey
// inspired from http://ryangreenberg.com/archives/2010/03/greasemonkey_jquery.php
// works with JQuery 1.5
// (c) 2011 Martin Monperrus
// (c) 2010 Ryan Greenberg
//
// Usage:
// $.ajax({
// url: '/p/',
// xhr: function(){return new GM_XHR();},
@tegomass
tegomass / iziToast.min.js
Created November 4, 2017 12:48
iziToast JS version 1.2.0 (oct. 2017)
/*
* iziToast | v1.2.0
* http://izitoast.marcelodolce.com
* by Marcelo Dolce.
*/
!function(t,e){"function"==typeof define&&define.amd?define([],e(t)):"object"==typeof exports?module.exports=e(t):t.iziToast=e(t)}("undefined"!=typeof global?global:window||this.window||this.global,function(t){"use strict";var e={},o="iziToast",n=(document.querySelector("body"),!!/Mobi/.test(navigator.userAgent)),s=/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor),i="undefined"!=typeof InstallTrigger,a="ontouchstart"in document.documentElement,r=["bottomRight","bottomLeft","bottomCenter","topRight","topLeft","topCenter","center"],l={info:{color:"blue",icon:"ico-info"},success:{color:"green",icon:"ico-success"},warning:{color:"orange",icon:"ico-warning"},error:{color:"red",icon:"ico-error"},question:{color:"yellow",icon:"ico-question"}},d=568,c={},u={id:null,"class":"",title:"",titleColor:"",titleSize:"",titleLineHeight:"",message:"",messageColor:"",messageSize:"",messageLineHeight:"",backgroundColor:"",theme
@tegomass
tegomass / iziToast.min.css
Last active November 4, 2017 12:48
iziToast CSS version 1.2.0 (oct. 2017)
/*
* iziToast | v1.2.0
* http://izitoast.marcelodolce.com
* by Marcelo Dolce.
*/
.iziToast-capsule{font-size:0;height:0;width:100%;transform:translateZ(0);backface-visibility:hidden;transition:transform .5s cubic-bezier(.25,.8,.25,1),height .5s cubic-bezier(.25,.8,.25,1)}.iziToast-capsule,.iziToast-capsule *{box-sizing:border-box}.iziToast-overlay{display:block;position:fixed;top:-100px;left:0;right:0;bottom:-100px;z-index:997}.iziToast{display:inline-block;clear:both;position:relative;font-family:'Lato',Tahoma,Arial;font-size:14px;padding:8px 45px 9px 0;background:rgba(238,238,238,.9);border-color:rgba(238,238,238,.9);width:100%;pointer-events:all;cursor:default;transform:translateX(0);-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;min-height:54px}.iziToast>.iziToast-progressbar{position:absolute;left:0;bottom:0;width:100%;z-index:1;background:rgba(255,255,255,.2)}.iziToast>.iziToast-progressbar>div{height:2px;width:100%
@tegomass
tegomass / cancelAJAX.js
Last active April 20, 2018 13:44 — forked from Integralist/cancelAJAX.js
Cancel all jQuery AJAX requests currently running
let xhrQueue = [];
$(document).ajaxSend(function(event,jqxhr,settings){
xhrQueue.push(jqxhr);
});
$(document).ajaxComplete(function(event,jqxhr,settings){
let i;
if((i=$.inArray(jqxhr,xhrQueue)) > -1){
xhrQueue.splice(i,1);
}
});
@tegomass
tegomass / gmail_image_resizer.user.js
Last active January 15, 2019 23:14
Add a button in the top-left of Gmail to resize the image in the body of your mails if they are larger than a specified value
// ==UserScript==
// @name gmail image resizer
// @namespace https://gist.github.com/tegomass/61083a3ea54fb6327b9c11cedbf3d161
// @description Add a button in the top-left of Gmail to resize the image in the body of your mails if they are larger than a specified value
// @include https://mail.google.com/*
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js
// @require https://gist.githubusercontent.com/tegomass/734b5a868f9222a6c1a89a42232768b5/raw/
// @exclude %exclude%
// @version 1.1
// @grant GM_addStyle