-
Notifications
You must be signed in to change notification settings - Fork 12
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
[FireMonkey][Feature Request] Expose WebExtension API browser.dns.getPublicSuffix(url) #503
Comments
Sure ...... |
Just a note. When
Quoting from #431 (comment):
|
JavaScript PSL parsing moduleI have written a PSL parsing module (check for details) for the new feature in v2.68 (used in toolbar popup). PSL Userscript APII can make the module available to userscripts. I have not decided on userscript API naming.
Providing const psl = await PSL.parse('example.com'); Comments are welcomed. PSATM, I am having problems exporting a module |
Would be cool to have some standardized way. Had the hope that we get it in FF directly, but seems they need some time and kind of overengineer this with a joint API ( w3c/webextensions#231 (comment) ).
Quickest approach I've seen so far is the implementation of Adblock:
For my userscripts I copyied the json in a separate js file, that I included as userscript in FireMonkey:
In the same userscript I can utilize it via "getBaseDomain('www.yahoo.co.uk')". Currently I'm executing this on every single link on any web page and had no noticeable performance impact for the overall page loading. However, I don't know how to measure the performance objectively apart from overall page loading and monitoring CPU usage. |
I regularly use a loop to test performances. I tested it just now. (() => {
let t;
// adjust the number based on function
const n = 1000;
// prepare the fixed data first
const hostname = 'mail.yahoo.co.uk';
console.log(PSL.parse(hostname));
// Object { subdomain: "mail", domain: "yahoo.co.uk", sld: "yahoo", tld: "co.uk" }
t = performance.now();
for (let i = 0; i < n; i++) {
// run the function
PSL.parse(hostname);
}
console.log(`Operation took ${performance.now() - t} milliseconds`);
// Operation took 46 milliseconds
})(); |
Awesome, many thanks. Will definitely use that in the future ;)
(html file, JS code is at the bottom) |
There is no doubt that Furthermore, in normal operations, where the parsing will be performed once (or a few times), the difference in speed is insignificant e.g. for one parsing, 0.046 millisecond vs 0.002 millisecond. I will do some more testing. Test Result for 1000
Test Result for 1000 including conversionFor this test,
When doing many parsing from a single Test Result for 1 including conversion
When doing a single parsing from a single |
BTW, |
I got a reply saying "Classes /inheritance is not supported". Initially, I was planning to create a const PSL = await GM.import('PSL'); Sadly, it is not possible in |
I re-wrote the new APIs again. Check Help for info. |
Hi Erosman,
there seems to be some progress on https://bugzilla.mozilla.org/show_bug.cgi?id=1315558 so that the FF internal publicSuffixList can be used by WebExtensions. Would be awesome when FM would expose this so that userscripts can make use of it:
Seems that the patch for this is currently being reviewed and this might become available in the upcoming FF versions. Would totally ease the handling of userscripts that make use of the PublicSuffixList (that always has to be included separately currently). Usage of the FF internal list might also improve performance.
The text was updated successfully, but these errors were encountered: