Extract Session from CityIndex iFrame

Extracts the session parameter from the iFrame URL and copies it to the clipboard

// ==UserScript==
// @name         Extract Session from CityIndex iFrame
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Extracts the session parameter from the iFrame URL and copies it to the clipboard
// @match        https://www.cityindex.com/*/forex-trading/*/
// @license MIT
// @grant        GM_setClipboard
// ==/UserScript==

(function() {
    'use strict';

    function extractSession() {
        const iframe = document.getElementsByTagName("iframe")[0];
        if (!iframe) {
            console.log("No iframe found.");
            return;
        }

        const url = new URL(iframe.src);
        const session = url.searchParams.get("session");

        if (session) {
            GM_setClipboard(session);
            console.log("Session copied to clipboard:", session);
        } else {
            console.log("Session parameter not found.");
        }
    }

    // Wait for the iframe to load
    window.addEventListener('load', () => {
        setTimeout(extractSession, 3000); // Wait a bit to ensure the iframe is loaded
    });
})();