Skip to content

Instantly share code, notes, and snippets.

View asif-jalil's full-sized avatar

Asif Jalil asif-jalil

View GitHub Profile
@asif-jalil
asif-jalil / injected.js
Created April 24, 2025 17:07
When building chrome extension there is no way to intercept request response. This way you can intercept reuqest
(function () {
const originalOpen = XMLHttpRequest.prototype.open
const originalSend = XMLHttpRequest.prototype.send
XMLHttpRequest.prototype.open = function (...args) {
console.log("request args", args)
this._url = args[1] // Capture URL
return originalOpen.apply(this, args)
}
function findNestedObject(object, keyToFind, valToFind) {
let foundObj;
JSON.stringify(object, (_, nestedValue) => {
if (nestedValue && nestedValue[keyToFind] === valToFind) {
foundObj = nestedValue;
}
return nestedValue;
});
return foundObj;
}
@asif-jalil
asif-jalil / filterNestedObject.js
Last active June 19, 2023 10:08
If you need to find specific key/value from a array of object or object of object (i,e multi level nested object), you can use this function. That's preety cool.
import { isObject } from "lodash";
export default function filterNestedObject(object, keyToFind, valToFind) {
if (!isObject(object)) {
return [];
}
const keys = Object.keys(object);
return keys
@asif-jalil
asif-jalil / axios.refresh_token.1.js
Created February 9, 2023 05:17 — forked from Godofbrowser/axios.refresh_token.1.js
Axios interceptor for refresh token when you have multiple parallel requests. Demo implementation: https://github.com/Godofbrowser/axios-refresh-multiple-request
// for multiple requests
let isRefreshing = false;
let failedQueue = [];
const processQueue = (error, token = null) => {
failedQueue.forEach(prom => {
if (error) {
prom.reject(error);
} else {
prom.resolve(token);
@asif-jalil
asif-jalil / publish-ghpages.md
Created August 30, 2021 11:24 — forked from tduarte/publish-ghpages.md
If you need to force push an subtree
git checkout master # you can avoid this line if you are in master...
git subtree split --prefix dist -b gh-pages # create a local gh-pages branch containing the splitted output folder
git push -f origin gh-pages:gh-pages # force the push of the gh-pages branch to the remote gh-pages branch at origin
git branch -D gh-pages # delete the local gh-pages because you will need it: ref