Files
script/Capture URL Transitions.user.js
2026-05-12 21:05:35 +02:00

59 lines
1.8 KiB
JavaScript

// ==UserScript==
// @name Capture URL Transitions
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Salva tutti i cambi di URL e i parametri authcode in una variabile globale
// @author Tu
// @match https://www.ilportaledeltrasporto.it/*
// @run-at document-start
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Variabile globale dove verranno salvati tutti i passaggi
window.capturedURLs = [];
function logURL(method) {
const currentURL = window.location.href;
const entry = {
timestamp: new Date().toLocaleTimeString(),
method: method,
url: currentURL
};
window.capturedURLs.push(entry);
// Stampa in console così puoi vederlo in tempo reale
console.log(`%chttps://medium.com/data-science/the-capture-recapture-method-dc9985b928da: %c${currentURL}`, "color: orange; font-weight: bold;", "color: cyan;");
// Se contiene l'authcode, evidenzialo con un alert o un log speciale
if (currentURL.includes('authcode')) {
console.error("!!! TROVATO AUTHCODE !!!", currentURL);
}
}
// Intercettiamo i metodi usati dalle Single Page Application (React)
const originalPushState = history.pushState;
const originalReplaceState = history.replaceState;
history.pushState = function() {
originalPushState.apply(this, arguments);
logURL('pushState');
};
history.replaceState = function() {
originalReplaceState.apply(this, arguments);
logURL('replaceState');
};
// Intercettiamo i tasti avanti/indietro del browser
window.addEventListener('popstate', function() {
logURL('popstate');
});
// Registriamo l'URL iniziale
logURL('initial-load');
})();