Skip to content

Instantly share code, notes, and snippets.

// ******************************************* p-cache.js ***********************************************
// What it does: it caches all requests a site makes (css, js, html, etc.) and when the app is offline it loads the cached version.
// On the Developer Tools' Network tab, if Disable cache is checked, requests will go to the network instead of the Service Worker. Uncheck that.
// Incognito mode skips the service worker as well!
var cacheName = 'pc-v2';
// Installing Service Worker
// "https://legends.io/index.html"
@Legends
Legends / how-to-view-source-of-chrome-extension.md
Last active April 17, 2023 10:22 — forked from paulirish/how-to-view-source-of-chrome-extension.md
How to view-source of a Chrome extension

Option 1: Command-line download extension as zip and extract

extension_id=jifpbeccnghkjeaalbbjmodiffmgedin   # change this ID
curl -L -o "$extension_id.zip" "https://clients2.google.com/service/update2/crx?response=redirect&os=mac&arch=x86-64&nacl_arch=x86-64&prod=chromecrx&prodchannel=stable&prodversion=44.0.2403.130&x=id%3D$extension_id%26uc" 
unzip -d "$extension_id-source" "$extension_id.zip"

Thx to crxviewer for the magic download URL.

@Legends
Legends / ScrapePage.cs
Last active June 22, 2020 11:49
Puppeteer Sharp - Scraping using C# and puppeteer
private async Task<DtoEst> LoadXXXAsync()
{
// downloads chromium to the local project, needed by Puppeteer Sharp for execution, takes about 2 min!
await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultRevision);
DtoEst dto = new DtoEst();
var url = "https://www.xxxxxx.xhtml";
#region SELECTORS
// https://stackoverflow.com/questions/45110893/select-elements-by-attributes-with-colon
<html>
<head> ... </head>
<body>
...
<script src="script.js">
....
</body>
</html>
const vw = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
const vh = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
// Math.max: --> return the heighest of these two provided
// document.documentElement.clientHeight = Height without scrollbars
// window.innerHeight = Height including scrollbars
<html>
<head>
<style>
.ind {
height: 10px;
width: 0%;
background-color: red;
position: fixed;
}
.wrapper {
position: relative;
background-color: red;
}
.childDiv {
position: absolute;
left: 50%;
top: 50%;
transform: translateX(-50%) translateY(-50%);
background-color: yellow;
console.log(getEventListeners(document.body));
// Animate.css also provides css classes to determine speed and delay:
// https://github.com/daneden/animate.css/#setting-delay-and-speed
// Add the `animated` class to your element:
<div id="personal" class="animated">
// Set animation via css:
#personal{
animation-name: fadeIn;
animation-delay: 0.3s;
"<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<meta http-equiv='X-UA-Compatible' content='ie=edge'>
<title>Document</title>
<link href='mystyle.css' rel='stylesheet'/></head>
<body>