Skip to content

Instantly share code, notes, and snippets.

@w35l3y
w35l3y / main.js
Last active August 29, 2015 14:22
XMLHttpRequest to GM_xmlhttpRequest
// Made from scratch based on https://github.com/ShiftSpace/gmrequest/blob/master/GMRequest.js
XMLHttpRequest = function () {
var _params = {
context : this,
headers : {},
onreadystatechange : function (detail) {
this.status = detail.status;
this.statusText = detail.statusText;
this.responseHeaders = detail.responseHeaders;
@w35l3y
w35l3y / html2canvas.js
Created June 12, 2015 14:03
Html 2 Canvas
// source https://github.com/niklasvh/html2canvas/releases/download/0.4.1/html2canvas.js
// modified to work with Greasemonkey
/*
html2canvas 0.4.1 <http://html2canvas.hertzen.com>
Copyright (c) 2013 Niklas von Hertzen
Released under MIT License
*/
(function(window, document, undefined){
class WaitForKeyElements {
list = [];
timer;
#selector;
#callback;
#props;
constructor (selector, callback, props) {
this.#selector = selector
@w35l3y
w35l3y / teste_estatico.html
Last active February 16, 2017 11:58
Testes
Funcionou!
@w35l3y
w35l3y / keybase.md
Last active February 28, 2017 18:48

 ### Keybase proof I hereby claim:

  • I am w35l3y on github.
  • I am wesleymenezes (https://keybase.io/wesleymenezes) on keybase.
  • I have a public key whose fingerprint is 90B5 E08A EF68 197D 5071 8676 B0B7 5DA0 C47C 8123

To claim this, I am signing this object:

{
@w35l3y
w35l3y / main.js
Created September 18, 2018 08:47
Obtém nome da coluna a partir do índice
function getColumnName (columnIndex) {
let chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
let base = chars.length;
let output = "";
while (0 <= columnIndex) {
let remainder = columnIndex % base;
columnIndex = Math.floor((columnIndex - remainder - 1) / base);
output = chars[remainder] + output;
@w35l3y
w35l3y / check.promise.js
Last active July 11, 2019 14:38
Verifica periodicamente o resultado de uma promessa
let check = (cb, timeout = 30000, step = 5000) => {
if (0 >= timeout) {
return Promise.reject("TIMEOUT");
}
return new Promise((resolve, reject) => {
setTimeout(() => {
console.log("Checking...", timeout);
cb().then(found => {
console.log("Checked!", found);
if (found) {
@w35l3y
w35l3y / fetch.js
Last active July 24, 2019 19:16
fetch to gm
function fetch (url, { method = "GET", headers = {}, body = null } = {}) {
return new Promise((resolve, reject) => {
if ("GET" === method) {
if (body) {
url += "?" + body;
body = null;
}
delete headers["Content-Type"];
}
console.log(method, url, body, headers);
@w35l3y
w35l3y / preload.js
Created July 22, 2019 17:46
djConfig preload
djConfig = {
isDebug: false,
layout: "",
usePlainJson: true,
baseUrl: "/ccm/web/dojo/",
locale: "en-gb",
localizationComplete: true
};
{"aaa":"bbbb"}