Hey,

I've thought a little more about the issue you have highlighted here.  

I've written something before that makes use of 

// @run-at document-start


My userscript redacts <https://github.com/damoclark/Redact> personal 
information on the webpage such as profile photos, names and so on for when 
I do public presentations.  So I had to solve the FOUC issue by ensuring 
things are redacted before they are displayed.  

The first thing my script does is:

console.log("Hiding body") ; 
GM_addStyle("body {visibility: hidden;}") ; 
console.log("Body hidden") ; 

Then it creates an event listener for  DOMContentLoaded that goes through 
the DOM and changes CSS to hide personal information.

After it has finished changing the DOM, it then allows the page to display:

window.document.getElementsByTagName("body")[0].style.visibility = "visible" 
;

With current GM, there is no FOUC, or any private information displayed 
before the css can be changed.

Given this already happens asynchronously, wouldn't this type of approach 
also work for the new async GM API?

Or are there other factors I'm not aware of?

Damo. 

On Tuesday, May 16, 2017 at 4:22:40 PM UTC+10, wOxxOm zOo wrote:
>
>
>
> On Monday, May 15, 2017 at 5:51:46 PM UTC+3, Anthony Lieuallen wrote:
>>
>> Where I've heard other people describe it, it sounds like they've made 
>> compromises to provide compatible calls.  Ones I'm not excited about 
>> emulating.
>>
>  
> Just in case, please don't rely on what people describe without it 
> investigating yourself.
>
> GM.getValue("serialized").then(sData => {
>>   var oData = JSON.parse(sData);
>>   // useful things happen here.
>> });
>>
>> Which is a change, but hopefully not a huge one.
>>
>
> This is a huge change actually and in many cases a breaking one. Just one 
> example off the top of my head: processing/altering a page while it's being 
> parsed/loaded using MutationObserver and "@run-at: document-start" so that 
> the changes are applied to an element before it's actually shown. Any async 
> API callback will be queued in a separate js engine event after a chunk of 
> the page is already processed and [usually] even rendered on screen. In 
> other words you'll introduce FOUC unless there'll be a method to have 
> GM_value injected alongside the script code (this is what Tampermonkey 
> does).
>

-- 
You received this message because you are subscribed to the Google Groups 
"greasemonkey-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/greasemonkey-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to