Skip to content

Instantly share code, notes, and snippets.

View codesorter2015's full-sized avatar
🏠
Working from home

Krish codesorter2015

🏠
Working from home
View GitHub Profile
@codesorter2015
codesorter2015 / README.md
Last active July 22, 2019 11:32 — forked from yckart/LICENSE.txt
getElementByXPath | Get DOM-Nodes by its XPath.
@codesorter2015
codesorter2015 / background.js
Created April 11, 2018 10:16 — forked from Rob--W/background.js
Implementation example of writable response bodies for Chromium extensions (API draft).
/**
* Implementation example of writable response bodies.
* Based on the draft of the Streams API (19 March 2014)
* https://dvcs.w3.org/hg/streams-api/raw-file/tip/Overview.htm
* Design document for response body reading/writing:
* https://docs.google.com/document/d/1iE6M-YSmPtMOsec7pR-ILWveQie8JQQXTm15JKEcUT8
*/
/* globals chrome, ByteStream, URL, XMLHttpRequest */
'use strict';
@codesorter2015
codesorter2015 / escaopeHTMLTag.js
Created April 11, 2018 10:18 — forked from Rob--W/escaopeHTMLTag.js
Example of safe HTML escaping using template literals
/* Example:
var someUnsafeStr = '<img>';
var result = escapeHTMLTag`<input value="${someUnsafeStr}">`;
console.log(result); // <input value="&lt;img&gt;">
// Questions? rob {at} robwu.nl
// */
function escapeHTML(str) {
// Note: string cast using String; may throw if `str` is non-serializable, e.g. a Symbol.
@codesorter2015
codesorter2015 / event-listeners.js
Created July 27, 2018 17:24 — forked from danburzo/README.md
Get all event listeners on the page in Google Chrome
var items = Array.prototype.slice.call(
document.querySelectorAll('*')
).map(function(element) {
var listeners = getEventListeners(element);
return {
element: element,
listeners: Object.keys(listeners).map(function(k) {
return { event: k, listeners: listeners[k] };
})
};
@codesorter2015
codesorter2015 / puppeteer_frame_example1.txt
Last active September 9, 2018 17:48
example of using puppeteer frames
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({headless: false});
const page = await browser.newPage();
await page.setContent('<iframe></iframe>');
// the page.frames()[0] is always a main frame.
const iframe = page.frames()[1];
// fetch the body element of the iframe
await Promise.all([
page.click('button[type="submit"]'),
page.waitForNavigation(),
]);
One workaround would be to listen for framenavigated event.
await Promise.all([
leftFrame.click('a[href="option2.html"]'),
new Promise(resolve => page.once('framenavigated', resolve))
@codesorter2015
codesorter2015 / es6-element-ready.js
Created September 19, 2018 09:27 — forked from jwilson8767/es6-element-ready.js
Wait for an element to exist. ES6, Promise, MutationObserver
/**
* Waits for an element satisfying selector to exist, then resolves promise with the element.
* Useful for resolving race conditions.
*
* @param selector
* @returns {Promise}
*/
export function elementReady(selector) {
return new Promise((resolve, reject) => {
let el = document.querySelector(selector);
const CDP = require('chrome-remote-interface');
CDP(async (client) => {
const {Network, Page, Target} = client;
Network.requestWillBeSent(({request, redirectResponse}) => {
console.log((redirectResponse || {}).url + ' -> ' + request.url);
});
Target.targetCreated((params) => {
if(params.targetInfo.type != "page") {
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Mutation Observers</title>
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="../video-pages/main.css">
</head>
<body>
<header>
@codesorter2015
codesorter2015 / reverse_proxy_setup.txt
Last active August 20, 2024 06:33
Reverse Proxy Setup with XAMPP/WAMP
Open apache httpd.conf file
Enable the following Modules by removing the # at the front of the line.
- LoadModule rewrite_module modules/mod_rewrite.so
- LoadModule proxy_module modules/mod_proxy.so
- LoadModule proxy_http_module modules/mod_proxy_http.so
- LoadModule proxy_connect_module modules/mod_proxy_connect.so
Open apache httpd-vhosts.conf
<VirtualHost *:80>
ProxyRequests On