Skip to content

Instantly share code, notes, and snippets.

View luckylooke's full-sized avatar

Ctibor Laky luckylooke

View GitHub Profile
@luckylooke
luckylooke / change_captcha_v2_lang.js
Created August 22, 2019 15:03
Changing reCAPTCHA v2 lang dynamically
function setCaptchaLang(lang) {
const container = document.getElementById('captcha_container');
// Get GoogleCaptcha iframe
const iframeGoogleCaptcha = container.querySelector('iframe');
// Get language code from iframe
const actualLang = iframeGoogleCaptcha.getAttribute("src").match(/hl=(.*?)&/).pop();
@luckylooke
luckylooke / fake_date.js
Last active July 22, 2022 13:53
fake Date in devTools for testing
// Context https://stackoverflow.com/a/72640597/861615
// Save the original `Date` function
const OriginalDate = Date;
const fakeDateArgs = [2022, 5, 3]; // beware month is 0 based
let fakeDate;
// Replace it with our own
Date = function Date(...args) {
// Called via `new`?
if (!new.target) {
// taken from https://stackoverflow.com/questions/11849562/how-to-save-the-output-of-a-console-logobject-to-a-file
(function(console){
console.save = function(data, filename){
if(!data) {
console.error('Console.save: No data')
return;
}
// Mouse vs touch detection, supporting devices which are capable of both
// by default set using touch for all touch enabled devices
let userUsesTouch =
'ontouchstart' in document.documentElement ||
navigator.maxTouchPoints > 0 ||
navigator.msMaxTouchPoints > 0;
if (userUsesTouch) {
catchMouse();