// ==UserScript== // @name Unbreak Snapchat web. Disable focus tracking and screenshot prevention // @namespace http://tampermonkey.net/ // @version 0.1 // @description This userscript improves the Snapchat web experience by disabling screenshot prevention features which don't prevent screenshots but do actively harm the usability. // @author @varenc // @match https://web.snapchat.com/* // @icon http://snapchat.com/favicon.ico // @license MIT // @run-at document-idle // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; function __unblockControlKeyEvents() { const modifyKeys = ["Control", "Meta", "Alt","Shift"]; // snapchat tries to disable console.log.. how mean. So we copy the real Console object from a new iframe const iframe = document.createElement("iframe"); iframe.style.display = "none"; document.body.appendChild(iframe); const nativeConsole = iframe.contentWindow.console; window.console=nativeConsole; for (var i = 0; i < arguments.length; i++) { var event_type = arguments[i]; document.addEventListener( arguments[i], function (e) { // console.log(`${event_type}[${i}]=`, e.key); if (modifyKeys.includes(e.key)) { e.preventDefault(); e.stopPropagation(); // e.stopImmediatePropagation(); console.log(`'${event_type}' event for '${e.key}' received and prevented:`, e); e.stopImmediatePropagation(); } }, true ); } } __unblockControlKeyEvents("keydown", "keyup", "keypress"); // Run a few extra times to ensure our event listeners take priority. setTimeout( () => __unblockControlKeyEvents("keydown", "keyup", "keypress"), 1000); setTimeout( () => __unblockControlKeyEvents("keydown", "keyup", "keypress"), 5000); setTimeout( () => __unblockControlKeyEvents("keydown", "keyup", "keypress"), 10000); document.hasFocus = function (){ return true } })();