Skip to content

Instantly share code, notes, and snippets.

@qwelias
qwelias / inject.js
Last active March 17, 2016 20:43
Custom logic for NightDev TwitchChat.
clearInterval(Chat.vars.queueTimer);
Chat.vars.queueTimer = setInterval(function() {
if (Chat.vars.queue.length > 0) {
var newLines = Chat.vars.queue.join('');
Chat.vars.queue = [];
$('#chat_box').prepend(newLines);
if (Chat.vars.preventClipping) {
var totalHeight = Chat.vars.max_height;
var currentHeight = $('#chat_box').outerHeight(true) + 5;
function escapeUI (str) {
if(!str) return str;
if(typeof str != 'string') return str;
return str.replace(/[\0\x08\x09\x1a\n\r"'\\\%]/g, function (char) {
switch (char) {
case "\0":
return "\\0";
case "\x08":
return "\\b";
case "\x09":
@qwelias
qwelias / form.reportValidity.js
Created September 22, 2016 13:47
HTMLFormElement.reportValidity() kind of polyfill
if ( !HTMLFormElement.prototype.reportValidity ) {
document.addEventListener( "DOMContentLoaded", function ( event ) {
var onclick = function () {
return true;
};
var forms = Array.from( document.querySelectorAll( 'form' ) );
forms.map( function ( f ) {
var btn = document.createElement( 'button' );
btn.onclick = onclick;
#!/bin/bash
# Delete all stopped containers
docker ps -q -f status=exited | xargs --no-run-if-empty docker rm
# Delete all dangling (unused) images
docker images -q -f dangling=true | xargs --no-run-if-empty docker rmi
function FindProxyForURL(url, host) {
const isReachClient = host.startsWith('reachclient') && host.endsWith('tv3cloud.com')
const isProxy = host === 'mitm.it'
if (isReachClient || isProxy) return 'PROXY 10.6.88.224:8888'
return 'DIRECT'
}
@qwelias
qwelias / ext.js
Last active January 8, 2018 00:04
/**
* class THIS extends Parent
*/
Function.prototype.inherits = function inherits(Parent) {
this.prototype = Object.create(Parent.prototype, {})
this.prototype.constructor = this
}
/**
* Constructor chain
const swre = new RegExp('\/messaging-\\d+\.js')
const rchre = new RegExp('\/reach\.js')
function FindProxyForURL(url, host) {
const isProxy = host === 'mitm.it'
switch (true) {
case isProxy: return 'PROXY 10.6.88.224:8888'
case swre.test(url):
case rchre.test(url): return 'PROXY 10.6.88.224:8888'
'''
In order to use this script, you need to have a file named overrides.txt and rules.py exist in
the same dir that you run mitmproxy.
An example of overrides.txt file might look like:
<urlRegExp> , <filePath> , [cmd]
rules.py should define cmd named functions as cmd(fileText, urlRegExpMatch)
Usage: mitmproxy -s overrides.py
<!DOCTYPE html>
<html>
<head>
<style media="screen">
html, body {
height: 100%;
width: 100%;
margin: 0;
font-size: 0;
}
@qwelias
qwelias / pathFrom.js
Created September 10, 2018 10:55
Ramda. Populate object dst path from src paths and rm all src paths.
const R = require('ramda');
const castArray = v => Array.isArray(v)
? v
: v == null
? v
: [v];
const pathFrom = R.curry((path, sources, obj) => sources.map(castArray).reduce((obj, source) => {
const current = R.path(path, obj);