Skip to content

Instantly share code, notes, and snippets.

View neopunisher's full-sized avatar
🎯
Focusing

Carter Cole neopunisher

🎯
Focusing
View GitHub Profile
@neopunisher
neopunisher / speechCommands.js
Created May 26, 2018 22:47
control stuff with your voice in the browser
(function(url, inj) {
inj(url).then(function() {
if (annyang) {
// Let's define a command.
var commands = {
'hello': function() { alert('Hello world!'); }
};
// Add our commands to annyang
@neopunisher
neopunisher / screenshotHtml.js
Created May 26, 2018 20:02
take a pic of the current html with svg magic
(function(url, inj) {
inj(url).then(function() {
html2canvas(document.body).then(function(canvas) {
document.body.appendChild(canvas);
});
})
})('https://html2canvas.hertzen.com/dist/html2canvas.min.js', (src, head = true) => new Promise(function(c, d) {
@neopunisher
neopunisher / youtube-screencap.js
Created May 25, 2018 05:30
take high quality screen stills from youtube with a button
(function(a){var b=a.createElement("button");b.innerText="Screencap";b.onclick=function(){var d=a.querySelector("video"),e=a.createElement("canvas"),b=e.getContext("2d"),c=a.createElement("a");e.width=d.videoWidth;e.height=d.videoHeight;b.drawImage(d,0,0);c.download=[ytcsi.data_.info.docid,d.currentTime,".png"].join("-");c.href=e.toDataURL();a.body.appendChild(c);c.click();a.body.removeChild(c)};a.querySelector("h1.title").appendChild(b)})(document);
@neopunisher
neopunisher / voicejammer.js
Created May 24, 2018 04:00
put on headphones and try and talk
var AudioContext = window.AudioContext || window.webkitAudioContext;
var audioContext = new AudioContext();
var synthDelay = audioContext.createDelay(0.2);
synthDelay.connect(audioContext.destination)
// request audio stream from the user's webcam
navigator.mediaDevices.getUserMedia({
audio: true
})
.then(function (stream) {
@neopunisher
neopunisher / injectSientinal.js
Created May 23, 2018 18:02
does stuff when things are added to the page... via https://github.com/muicss/sentineljs
(function(style, func){
document.addEventListener('sentinel-load', function(){
sentinel.on(style, func);
})
var a=document.createElement("script");a.src='//cdn.rawgit.com/muicss/sentineljs/0.0.4/dist/sentinel.min.js';a.type="text/javascript";
document.head.appendChild(a);
})('.my-div', function(el) {
el.innerHTML = 'The sentinel is always watching.';
})
let tokens = [];
let dsl = new Proxy({}, {
get(state, token) {
// Before anything, we're going to try and access a variable
if (tokens.length === 0 && state[token] !== undefined) {
return state[token];
}
tokens.push(token);
const rule = grammar[tokens[0]];
(function(url1, url2, url3, inj) {
inj(url1).then(() => inj(url2)).then(() => inj(url3)).then(async function() {
var canvas = document.createElement('canvas')
var ctx = canvas.getContext('2d');
const net = await posenet.load();
var processfn = async function(video, dt) {
ctx.drawImage(video, 0, 0);
@neopunisher
neopunisher / injectPico.js
Last active May 18, 2018 19:55
inject pico face detect
(function(){var urls = Array.from(arguments), inj = urls.pop();Promise.all(urls.map(inj)).then(function(){
var initialized = false;
var canvas = document.createElement('canvas')
document.body.appendChild(canvas)
var button = document.createElement('button')
function lines(elem, limit = 3, delimiter = ' '){
const width = elem.clientWidth
const words = elem.innerText.split(delimiter)
const ctx = document.createElement('canvas').getContext('2d'),
fnt = window.getComputedStyle(elem).getPropertyValue('font')
ctx.font = fnt
@neopunisher
neopunisher / inject-react.js
Last active January 22, 2021 06:42
Pull react into the page
(function(inj){
inj('https://unpkg.com/react@16/umd/react.development.js').then(()=>inj('https://unpkg.com/react-dom@16/umd/react-dom.development.js')).then(()=>inj('https://unpkg.com/[email protected]/babel.min.js')).then(function(){
var out=document.createElement("div");out.id='testing';
document.body.appendChild(out)
console.log('loaded babel')
Babel.registerPlugin('eval_wrapper', function eval_wrapper() { return {visitor: {
FunctionDeclaration(path) {
console.log('a func')
// debugger
},