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 url = process.env.URL || 'https://lit-element.polymer-project.org/'; | |
(async () => { | |
const browser = await puppeteer.launch(); | |
const page = await browser.newPage(); | |
await page.goto(url); | |
await page.evaluate(() => { | |
// loop through elements and copy shadow to inner |
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
//get base url | |
const getUrl = window.location; | |
const baseUrl = getUrl .protocol + "//" + getUrl.host + "/"; | |
// the string you want to append | |
const stringToAdd = "test/" | |
// get all a tags | |
let elements = document.getElementsByTagName('a'); | |
for (let node of elements) { | |
// is this internal to the site? If so update the link | |
if(node.href.startsWith(baseUrl)){ |
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
// npm install puppeteer | |
const puppeteer = require('puppeteer'); | |
/* variables to allow for user-agent / screensize choice | |
example use: URL='https://tamethebots.com' useragent='Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.96 Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)' viewportw=412 viewporth=732 node codeCover.js | |
*/ | |
const url = process.env.URL || 'https://www.example.com'; | |
const useragent = process.env.useragent || 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'; | |
const viewportw = process.env.viewportw || 1920; | |
const viewporth = process.env.viewporth || 1696; |
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'); | |
/* variables to allow for user-agent / device. | |
example use: URL='https://tamethebots.com' useragent='Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.96 Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)' viewportw=412 viewporth=732 node shift.js | |
*/ | |
const url = process.env.URL || 'https://tamethebots.com/'; | |
const useragent = process.env.useragent || 'Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.96 Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'; | |
const viewportw = process.env.viewportw || 412; | |
const viewporth = process.env.viewporth || 732; | |
const threeGee = { | |
'offline': false, |
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
//Run this in the console, will cooy the shadow DOM to the light. Will only work for open ones, and will not recurse nested shadow DOMs | |
for (let elMnt of document.getElementsByTagName('*')) { | |
if (elMnt.shadowRoot) elMnt.innerHTML = elMnt.shadowRoot.innerHTML; | |
} |
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
//Run this in the console, will cooy the shadow DOM to the light. Will only work for open ones, and will not recurse nested shadow DOMs | |
for (let elMnt of document.getElementsByTagName('*')) { | |
if (elMnt.shadowRoot) elMnt.innerHTML = elMnt.shadowRoot.innerHTML; | |
} |
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
//Run this in the console, will cooy the shadow DOM to the light. Will only work for open ones, and will not recurse nested shadow DOMs | |
for (let elMnt of document.getElementsByTagName('*')) { | |
if (elMnt.shadowRoot) elMnt.innerHTML = elMnt.shadowRoot.innerHTML; | |
} |
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
/* | |
usage: | |
node usedcss url=<page_to_test> filename=<required_file_name> viewport=<widthxheight> ua='<my user agent>' | |
filename, viewport & ua optional, | |
Example: | |
node usedcss url=https://tamethebots.com filename=ttb_used.css viewport=360x640 ua='css coverage script' | |
Updated to print original stylesheet URL | |
*/ |
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 currURL = `${window.location.protocol}//${window.location.host}${window.location.pathname}${window.location.search}` | |
let outputString = '' | |
for (var idx in document.links) { | |
const ancString = `${document.links[idx]}` | |
if (ancString.includes('#')) { | |
const anchParts = ancString.split('#') | |
if (anchParts[0] === currURL) { | |
| |
if (!document.getElementById(anchParts[1])) { | |
outputString += `${document.links[idx]}\n` |
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'); | |
// throttle network and cpu? | |
const throttle = true; | |
// viewport sizes | |
const viewportw = 412; | |
const viewporth = 732; | |
// url to test | |
const theurl = 'https://tamethebots.com'; | |
(async() => { |
OlderNewer