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

Weird blank page #226

Closed
legnaleurc opened this issue Jul 13, 2015 · 4 comments
Closed

Weird blank page #226

legnaleurc opened this issue Jul 13, 2015 · 4 comments
Labels
Milestone

Comments

@legnaleurc
Copy link

Tampermonkey version: BETA v3.12.4708
Chrome 43.0.2357.132 (64-bit)

Please install the following script and visit http://www1.macys.com/shop/product/navy-yard-8-piece-reversible-bedding-ensembles?ID=764254&CategoryID=26795

// ==UserScript==
// @name         My Fancy New Userscript
// @namespace    http://your.homepage/
// @version      0.1
// @description  enter something useful
// @author       You
// @match        http://www1.macys.com/shop/product/navy-yard-8-piece-reversible-bedding-ensembles?ID=764254&CategoryID=26795
// @grant        unsafeWindow
// @run-at       document-start
// ==/UserScript==

for (var i = 0; i < 3; ++i) {
  console.info(document);
}

The page is visually blank.

The weird thing is you have to

  1. grant unsafeWindow
  2. run-at document-start
  3. reference document 3-times or more

If any condition is not matched, then the page renders fine.

@derjanb derjanb added the bug label Jul 13, 2015
@derjanb derjanb added this to the 3.12 milestone Jul 13, 2015
@derjanb
Copy link
Member

derjanb commented Jul 14, 2015

Fixed: http://tampermonkey.net/changelog.php?version=3.12.4712&ext=gcal
Thanks for your bug report.

@derjanb derjanb closed this as completed Jul 14, 2015
@devnoname120
Copy link

@derjanb Could you please provide us more details about how the bug was fixed (and what did cause it exactly)? I am interested in the technical details. 😃

@derjanb
Copy link
Member

derjanb commented Jul 15, 2015

Each page gets some Tampermonkey code injected. It consists of two parts, one is located at the Chrome extension context and one directly at the page. Both parts live in a separated world, but they share the DOM. That's why they can use events for communication.

If now document.write is called after the document was closed all event listeners are gone. In order to workaround this TM wraps this function to re-register the event listeners, but this happens only if a userscript uses the document object.

The problem now was that each time the document was referenced by a userscript the write function was wrapped again. Subsequent document.write calls caused multiple event listener (re-)registrations. This caused each TM internal event to be processed multiple times and caused a lot of load.
I'm not sure which of these issues finally broke the page but when I looked at it the body height was far to small. So maybe some code tried to calculate the body height, but failed due to the timing issues caused by TM.

Hope this helped. :)

@devnoname120
Copy link

Thank you for the explanations!

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

No branches or pull requests

3 participants