This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fse = require('fs-extra'); | |
const puppeteer = require('puppeteer'); | |
const getPdf = (page) => { | |
let url = await page.url(); | |
return page.evaluate(url => { | |
return new Promise(async resolve => { | |
const reader = new FileReader(); | |
const response = await window.fetch(url, { | |
credentials: 'same-origin', | |
method: 'POST' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const puppeteer = require('puppeteer'); | |
(async () => { | |
try { | |
const browser = await puppeteer.launch({ | |
headless: false, | |
}) | |
const page = await browser.newPage(); | |
await page.setBypassCSP(true); | |
await page.goto('https://github.com/google'); | |
await page.addScriptTag({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*Immediately Executing Function: | |
You can execute a function immediately after you define it. | |
Simply wrap the function in parentheses () and invoke it | |
The reason for having an IEF is to create a new variable scope. | |
Example: | |
-------- | |
*/ | |
(function test() { console.log('test was executed!'); })(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const puppeteer = require('puppeteer'); | |
(async () => { | |
const browser = await puppeteer.launch({headless:false}); | |
const page = await browser.newPage(); | |
let url = 'youtube url'; | |
await page.goto(url); | |
await page.evaluate(() => { | |
self.moHandler = { | |
changesObserver: function (mutation) { | |
if (mutation.type === 'attributes'){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function loadScript(src) { | |
return new Promise((resolve, reject) => { | |
const script = document.createElement('script'); | |
script.src = src; | |
script.onload = resolve; | |
script.onerror = reject; | |
document.head.appendChild(script); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
handler = { | |
get: function(target, property, receiver) { | |
let targetObj = target[property]; | |
if(typeof targetObj == "function") { | |
return (...args) => target[property].apply(target,args) | |
} else { | |
return targetObj; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
location = location | |
... and a 534 other ways to reload the page with JavaScript | |
location = location | |
location = location.href | |
location = window.location | |
location = self.location | |
location = window.location.href | |
location = self.location.href | |
location = location['href'] | |
location = window['location'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const puppeteer = require('puppeteer'); | |
const proxyChain = require('proxy-chain'); | |
(async() => { | |
const oldProxyUrl = 'http://bob:[email protected]:8000'; | |
const newProxyUrl = await proxyChain.anonymizeProxy(oldProxyUrl); | |
// Prints something like "http://127.0.0.1:45678" | |
console.log(newProxyUrl); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ProxyRequests Off | |
ProxyPreserveHost On | |
<Proxy pos.##REDACTED###.za> | |
Order deny,allow | |
Allow from all | |
</Proxy> | |
RewriteEngine On | |
RewriteCond %{HTTP:Connection} Upgrade [NC] | |
RewriteRule /(.*) ws://localhost:8080/$1 [P,L] | |
ProxyPass /socket.io http://localhost:8080/socket.io/ retry=0 timeout=5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<VirtualHost *:80> | |
ServerName test.localhost | |
Header always set Access-Control-Allow-Origin "*" | |
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT" | |
Header always set Access-Control-Max-Age "1000" | |
RewriteEngine On | |
RewriteCond %{HTTP:Connection} Upgrade [NC] | |
RewriteRule /(.*) ws://localhost:3001/$1 [P,L] | |
NewerOlder