Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] JSON.parse parsing error occurred in a specific website #1980

Closed
F9y4ng opened this issue Jan 18, 2024 · 3 comments
Closed

[BUG] JSON.parse parsing error occurred in a specific website #1980

F9y4ng opened this issue Jan 18, 2024 · 3 comments

Comments

@F9y4ng
Copy link

F9y4ng commented Jan 18, 2024

(Please fill out the issue template with your details)

Expected Behavior

Can get the correct JSON.parse method.

Actual Behavior

Sequence of actions:

  1. Create the following script [1]
  2. Visit https://ww7.manganelo.tv/
  3. JSON.parse method reports error

tm

  • Chromium: 120
  • TM: 5.0.1/5.0.6192 BETA
  • OS: WIN10

script [1]

(Please give an example of the script if applicable.)

// ==UserScript==
// @name         New Userscript
// @namespace    http://tampermonkey.net/
// @version      2024-01-18
// @description  try to take over the world!
// @author       You
// @match        *://*/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        unsafeWindow
// @run-at       document-start
// ==/UserScript==

(function() {
  'use strict';
  console.log(1,JSON);
  console.log(2,JSON.stringify);
  console.log(3,JSON.parse);
})();
@F9y4ng
Copy link
Author

F9y4ng commented Jan 18, 2024

I wonder if it would be better to provide a new API interface through TM extension to obtain the original methods (including window.console, window.JSON, etc.)?

@F9y4ng F9y4ng closed this as completed Jan 18, 2024
@7nik
Copy link

7nik commented Jan 18, 2024

Sandboxed window should contain only original non-modified globals anyway. This bug doesn't occur in FF.

You could workaround it with // @sandbox DOM (unless you need unsafeWindow) but it still requires allowing this mode by the user in the TM settings.

@F9y4ng
Copy link
Author

F9y4ng commented Jan 18, 2024

Sandboxed window should contain only original non-modified globals anyway. This bug doesn't occur in FF.

You could workaround it with // @sandbox DOM (unless you need unsafeWindow) but it still requires allowing this mode by the user in the TM settings.

Thanks, I used GM_addElement("iframe") to get JSON.parse to temporarily solve this ISSUE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants