Minimal ChatGPT Message Logger

Listen for postMessage from parent and log to console

当前为 2025-05-12 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Minimal ChatGPT Message Logger
  3. // @description Listen for postMessage from parent and log to console
  4. // @match https://chatgpt.com/*
  5. // @version 0.0.1.20250512162640
  6. // @namespace https://greasyfork.org/users/1435046
  7. // ==/UserScript==
  8.  
  9. (function () {
  10. 'use strict';
  11.  
  12. // ‘window’ is the global object representing the page’s JavaScript environment.
  13. // addEventListener: attach (“add”) a function to run when a named event (“message”) occurs.
  14. window.addEventListener('message', function (event) {
  15. // When postMessage is used, this handler fires.
  16. // console.log: print to the browser’s developer console.
  17. console.log('Received message from parent window:', event.data);
  18. });
  19. })();