// --- Temporary Click Interceptor/Redispatcher ---
const clickInterceptor = (clickEvent) => {
if (!clickEvent._isSimulatedByScript) return;
// console.log("Capture-phase click interceptor RUNNING.");
clickEvent.preventDefault();
clickEvent.stopPropagation();
clickEvent.stopImmediatePropagation();
// console.log("Original simulated click propagation stopped.");
const interceptorRef = currentClickInterceptor;
currentClickInterceptor = null;
document.removeEventListener('click', interceptorRef, true);
// console.log("Capture-phase click interceptor REMOVED.");
// console.log("Redispatching a new click event to:", targetElementForRedispatch);
const redispatchEvent = new MouseEvent('click', { bubbles: true, cancelable: true });
targetElementForRedispatch.dispatchEvent(redispatchEvent);
// console.log("New click event redispatched.");
};
currentClickInterceptor = clickInterceptor;
document.addEventListener('click', clickInterceptor, true);
// console.log("Capture-phase click interceptor ADDED.");
// Activate JSON interception
capturedShortcode = null;
isInterceptingJson = true; // Activate flag
// console.log("JSON interception activated.");
// Dispatch the INITIAL simulated click
try {
const initialClickEvent = new MouseEvent('click', { bubbles: true, cancelable: true });
initialClickEvent._isSimulatedByScript = true;
el.dispatchEvent(initialClickEvent);
// console.log("Initial simulated click dispatched.");
} catch (clickError) {
console.error("Error dispatching initial simulated click:", clickError);
cleanupState("initial_click_error");
return;
}
// Wait for the shortcode
const maxWait = 1000;
const interval = 50;
let waited = 0;
let checkInterval = null;
checkInterval = setInterval(() => {
if (capturedShortcode) {
clearInterval(checkInterval);
console.log(`Shortcode captured: ${capturedShortcode}. Opening new tab AND calling history.back() immediately.`);
// GM_log(`Shortcode captured: ${capturedShortcode}. Opening new tab AND calling history.back() immediately.`);
const url = `https://www.instagram.com/p/${capturedShortcode}/`;
let newTabOpened = false;
try {
const newTab = window.open(url, '_blank');
if (newTab) {
newTabOpened = true;
} else {
console.warn("window.open returned null or was blocked, but proceeding with history.back().");
}
} catch(openError) {
console.error("window.open failed:", openError);
// We still try history.back() even if window.open fails
}
// === ВЫЗЫВАЕМ history.back() СРАЗУ ===
console.log("Calling history.back() NOW...");
// GM_log("Calling history.back() NOW...");
try {
history.back();
} catch (backError) {
console.error("history.back() failed:", backError);
}
// Финальная очистка (флаг уже сброшен интерцептором)
cleanupState("after_open_and_back");
} else if (!isInterceptingJson) {
// This case might happen if JSON parse happens but doesn't contain the shortcode
// or if cleanup was called for some other reason before timeout
clearInterval(checkInterval);
console.warn("JSON interception stopped, but no shortcode was captured.");
cleanupState("interception_stopped_no_code");
} else {
// Still waiting...
waited += interval;
if (waited >= maxWait) {
clearInterval(checkInterval);
console.warn(`Shortcode not captured within ${maxWait}ms.`);
cleanupState("timeout");
}
}
}, interval);
}); // end mousedown listener
}); // end candidates.forEach
}
});
}
}
}); // end observer
// Start observing
observer.observe(document.body, { childList: true, subtree: true });
console.log("MutationObserver started.");
})();
// ==UserScript==
// @name Instagram Middle Click (Race Condition + history.back)
// @namespace http://tampermonkey.net/
// @version 1.0.1
// @description Opens post in new tab, immediately calls history.back() to attempt cancelling navigation.
// @author GPT & User
// @match https://www.instagram.com/*
// @grant GM_log
// ==/UserScript==
(function() {
'use strict';
console.log("Instagram Likes Middle Click Script (v1.0.1) Loaded.");
const originalJsonParse = JSON.parse;
let capturedShortcode = null;
let isInterceptingJson = false;
let currentClickInterceptor = null;
// --- JSON Interceptor ---
JSON.parse = function(text, reviver) {
const parsed = originalJsonParse.call(this, text, reviver);
try {
if (isInterceptingJson) {
const potentialShortcode = parsed?.payload?.result?.route_match_infos?.[0]?.instanceParams?.shortcode;
if (potentialShortcode && typeof potentialShortcode === 'string') {
console.log(`JSON Interceptor: Found potential shortcode: ${potentialShortcode}`);
capturedShortcode = potentialShortcode;
isInterceptingJson = false; // Deactivate immediately
// console.log("JSON interception deactivated after finding code.");
}
}
} catch (e) { /* Ignore errors */ }
return parsed;
};
// --- Cleanup Function ---
function cleanupState(reason = "unknown") {
// console.log(`Cleanup state called (${reason}).`);
isInterceptingJson = false;
if (currentClickInterceptor) {
const interceptorRef = currentClickInterceptor;
currentClickInterceptor = null;
document.removeEventListener('click', interceptorRef, true);
}
// console.log("Cleanup complete: JSON interception deactivated.");
}
// --- Mutation Observer ---
const observer = new MutationObserver((mutationsList) => {
for (const mutation of mutationsList) {
if (mutation.type === 'childList') {
mutation.addedNodes.forEach(node => {
if (node.nodeType === Node.ELEMENT_NODE) {
const candidates = node.matches('div[role="button"][aria-label*="публикации"]') && !node.hasAttribute('data-gpt-bound')
? [node]
: node.querySelectorAll('div[role="button"][aria-label*="публикации"]:not([data-gpt-bound])');
candidates.forEach(el => {
el.setAttribute('data-gpt-bound', 'true');
el.addEventListener('mousedown', e => {
if (e.button !== 1) return;
// console.log("Middle click detected on:", el);
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
const targetElementForRedispatch = el.parentElement;
if (!targetElementForRedispatch) {
console.error("Cannot find parent element for redispatch!");
return;
}
Типа чтобы вместо обычной настройки второго пространства в меню настроек добавлялось фэйковой пункт с предложением типа "добавьте второе пространство"?) чтобы те кто шарятся по меню настроек видели что вы его еще не создавали? так чтоли?
скрытая папка от samsung - это всё очень хорошо, но оно оставляет следы
Типа чтобы вместо обычной настройки второго пространства в меню настроек добавлялось фэйковой пункт с предложением типа "добавьте второе пространство"?) чтобы те кто шарятся по меню настроек видели что вы его еще не создавали? так чтоли?
Так этой фиче уже столько лет, что ее даже и там знают :)
А смысл-то в чем? "Вас остановил патруль"?
Так этой фиче уже столько лет, что ее даже и там знают :)
P.S.: У меня назывался Private Space...а не Parallel...
{"status":404,"request":"GET /j.zip HTTP/1.1","remote_addr":"1.1.1.1","remote_user":"","body_bytes_sent":134,"http_referer":"","http_user_agent":"TelegramBot (like TwitterBot)","time_local":"24/Jan/2025:04:49:41 +0300","request_time":0.000}
{"status":404,"request":"GET /j.zip HTTP/1.1","remote_addr":"2.2.2.2","remote_user":"","body_bytes_sent":197,"http_referer":"","http_user_agent":"Mozilla/5.0 (Linux; Android 11; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.6778.260 Mobile Safari/537.36","time_local":"24/Jan/2025:04:49:42 +0300","request_time":0.000}
2025-01-24 04:49:41,410 fail2ban.filter [535953]: ERROR Failed to process line: '{"status":404,"request":"GET /j.zip HTTP/1.1","remote_addr":"1.1.1.1","remote_user":"","body_bytes_sent":134,"http_referer":"","http_user_agent":"TelegramBot (like TwitterBot)","time_local":"24/Jan/2025:04:49:41 +0300","request_time":0.000}', caught exception: IndexError('string index out of range')
2025-01-24 04:49:43,412 fail2ban.filter [535953]: INFO [error-404] Found 2.2.2.2 - 2025-01-24 04:49:42
2025-01-24 04:49:43,594 fail2ban.actions [535953]: NOTICE [error-404] Ban 2.2.2.2