Skip to content

Instantly share code, notes, and snippets.

View mantou132's full-sized avatar
🎯
Focusing

mantou mantou132

🎯
Focusing
View GitHub Profile
@mantou132
mantou132 / 宁波市专业监理工程师网络培训平台
Last active November 17, 2019 11:31
网站视频培训自动验证
document.querySelector('#videoVerifyContent').remove();
async function validator() {
const ocr = async url => {
const { default: Tesseract } = await import(
"https://dev.jspm.io/tesseract.js"
);
const data = await Tesseract.recognize(
url ||
"https://ware.cdeledu.com/cdel_ware/common/makeArithmeticCode.shtm?random=0.6212206602916508"
);
@mantou132
mantou132 / serviceworker.js
Last active June 5, 2020 18:53 — forked from ngokevin/serviceworker.js
Service Worker Template - cache-else-network + network-else-cache
const VERSION = '0.0.1';
const assetsToCache = [...new Set([self.location.pathname, '/'])].map(
path => self.location.origin + path,
);
self.addEventListener('install', () => {
self.skipWaiting();
self.caches.open(VERSION).then(cache => {
cache.addAll(assetsToCache);
@mantou132
mantou132 / PortAwareSharedWorker.ts
Created September 29, 2022 12:52 — forked from Akxe/PortAwareSharedWorker.ts
PortAwareSharedWorker, shared worker that know who is still connected and who is not
/// <reference lib="webworker" />
type SharedWorkerPort = MessagePort | DedicatedWorkerGlobalScope;
class PortAwareSharedWorkerPort<T extends SharedWorkerPort = SharedWorkerPort, D = any> {
private readonly weakRef: WeakRef<T>;
private disconnected = false;
constructor(
port: T,
onMessage: (eventData: D) => void,