Skip to content

Instantly share code, notes, and snippets.

View matyasfodor's full-sized avatar
🦕

Mátyás Fodor matyasfodor

🦕
  • BenevolentAI
  • London
View GitHub Profile
function detectWebkitRequestFileSystem(e, t) {
return new Promise(function(e) {
if (!window.webkitRequestFileSystem)
return e(null);
window.webkitRequestFileSystem(window.TEMPORARY, 1, e.bind(null, !1), e.bind(null, !0))
}
)
}
@matyasfodor
matyasfodor / incognitoTrick.js
Created December 27, 2017 04:43
Tampermonkey script to fake incognito check
// ==UserScript==
// @name Incognito trick
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Prevent sites detecting if you're in incognito by calling the success callback of webkitRequestFileSystem even if it's failing.
// @author You
// @run-at document-start
// @match *://*/*
// @grant none
// ==/UserScript==
(function () {
// Monkey patch `webkitRequestFileSystem` to call success callback even if the request failed
(function(webkitRequestFileSystem) {
window.webkitRequestFileSystem = function(type, size, successCallback, errorCallback) {
webkitRequestFileSystem(type, size, successCallback, successCallback);
}
})(window.webkitRequestFileSystem);
})();
var incognito = function(require, module, exports) {
"use strict";
function isWebkitRequestFileSystem() {
return !!window.webkitRequestFileSystem
}
function isFirefoxIndexedDB() {
return !!window.indexedDB && /Firefox/.test(window.navigator.userAgent)
}
function isIE10PlusOrEdge() {
if (document.documentMode) {
// Hack for monkey patching $scope.$watch
this.$scope.$watch = ((originalWatchFn) => {
const scope = this.$scope;
// tslint:disable-next-line
return function(watchExpression, listener, objectEquality) {
// tslint:disable-next-line
const wrappedCB = function () {
console.log(watchExpression, arguments[0], arguments[1]);
listener.apply(null, arguments);
};
def record_factory(cls_name, field_names):
# ...
def __hash__(self):
try:
return hash(self.id)
except AttributeError:
raise TypeError('unhashable type {}'.format(cls_name))
def __eq__(self, other):
try:
return hash(self) == hash(other)
def record_factory(cls_name, field_names):
# ...
def __hash__(self):
try:
return hash(self.id)
except AttributeError:
raise TypeError('unhashable type {}'.format(cls_name))
# ...
cls_attrs = dict(__slots__ = field_names,
__init__ = __init__,
def record_factory(cls_name, field_names):
# ...
def _asdict(self):
return {k: getattr(self, k) for k in self.__slots__}
cls_attrs = dict(__slots__ = field_names,
__init__ = __init__,
__iter__ = __iter__,
__repr__ = __repr__,
__hash__ = __hash__,
nt = namedtuple('X', 'a b')
mydict = {}
dict[nt(1, 2)] = 5
dict[nt(1, 2)]
# 5
>>> hash(nt(1, 2))
3713081631934410656
>>> hash(nt(1, {'a': 5}))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'dict'