Skip to content

Instantly share code, notes, and snippets.

View jaronwanderley's full-sized avatar

Jaron Wanderley jaronwanderley

View GitHub Profile
@jaronwanderley
jaronwanderley / background.js
Created August 9, 2018 15:17 — forked from danharper/background.js
Bare minimum Chrome extension to inject a JS file into the given page when you click on the browser action icon. The script then inserts a new div into the DOM.
// this is the background code...
// listen for our browerAction to be clicked
chrome.browserAction.onClicked.addListener(function (tab) {
// for the current tab, inject the "inject.js" file & execute it
chrome.tabs.executeScript(tab.ib, {
file: 'inject.js'
});
});
setTimeout(function() {
function getAllModules() {
return new Promise((resolve) => {
const id = _.uniqueId("fakeModule_");
window["webpackJsonp"](
[],
{
[id]: function(module, exports, __webpack_require__) {
resolve(__webpack_require__.c);
}
@jaronwanderley
jaronwanderley / validateCpfCnpj.js
Last active June 16, 2021 12:45
Validation for CPF and CNPJ
const isString = value => typeof value === 'string'
const format = value => value.replace(/[^\d]+/g, '')
const isValidNumber = (value, count) => format(value).length === count && !format(value).match(/(\d)\1{10}/)
const validator = value => format(value)
.split('')
.splice(format(value).length - 2)
.map( el => +el )
const toValidate = (value, end, start = 0) => format(value)
.split('')