Skip to content

Instantly share code, notes, and snippets.

@Zod-
Last active August 29, 2015 14:14
Show Gist options
  • Save Zod-/b887f25ac9c849a27bf3 to your computer and use it in GitHub Desktop.
Save Zod-/b887f25ac9c849a27bf3 to your computer and use it in GitHub Desktop.
All my hats are belong to me - zod
// ==UserScript==
// @name InstaSynchP Anti Hat Stealer
// @namespace InstaSynchP
// @description All my hats are belong to me - zod
// @version 1.0.1
// @author Zod-
// @source https://gist.github.com/Zod-/b887f25ac9c849a27bf3
// @license MIT
// @include *://instasync.com/r/*
// @include *://*.instasync.com/r/*
// @grant none
// @run-at document-start
// @require https://greasyfork.org/scripts/5647-instasynchp-library/code/code.js?version=49210
// ==/UserScript==
function AntiHatStealer() {
"use strict";
this.version = '1.0.1';
this.name = 'InstaSynchP Anti Hat Stealer';
this.settings = [{
'label': 'Prevent with random emote',
'id': 'anti-random-hat-emote',
'type': 'checkbox',
'default': true,
'section': ['Anti Steal Hats']
}, {
'label': 'Prevent with fixed emote',
'id': 'anti-fixed-hat-emote',
'type': 'text',
'default': '',
'size': 10,
'section': ['Anti Steal Hats']
}, {
'label': 'Prevent hat steals',
'id': 'enabled-anti-hat-stealer',
'type': 'checkbox',
'default': true,
'section': ['Anti Steal Hats']
}];
}
AntiHatStealer.prototype.executeOnce = function () {
'use strict';
var th = this;
var mes = '';
function sendMessage(message) {
var e = $.Event("keypress");
e.which = e.keyCode = 13;
$('#cin').val(message).trigger(e);
}
events.on(th, 'InputKeypress[13]', function (event, message) {
mes = message;
});
events.on(th, 'InputKeyup[13]', function () {
try{
if ((mes.trim() !== '/jpb' && mes.trim() !== '/fed') ||
!gmc.get('enabled-anti-hat-stealer')) {
return;
}
var oldInput = $('#cin').val(),
emotes = Object.keys(window.$codes),
emote = gmc.get('anti-fixed-hat-emote');
if (gmc.get('anti-random-hat-emote')) {
emote = '/' + emotes[Math.floor(Math.random() * emotes.length)]
}
sendMessage(emote);
$('#cin').val(oldInput);
}catch(error){
console.error(error);
}
});
};
window.plugins = window.plugins || {};
window.plugins.antiHatStealer = new AntiHatStealer();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment