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

Improve content injection algorithm #1099

Closed
confessor-adguard opened this issue May 16, 2016 · 7 comments
Closed

Improve content injection algorithm #1099

confessor-adguard opened this issue May 16, 2016 · 7 comments

Comments

@confessor-adguard
Copy link

confessor-adguard commented May 16, 2016

Total content injection algorithm reworking.

First and foremost, this should solve issues with document-start userscripts, resolve some of the known conflicts (AdsBypasser, YouTube+), and also optimize usage of ad blocker scripts and styles.

@ameshkov ameshkov changed the title Improve content injection methodology Improve content injection algorithm Jun 8, 2016
@confessor-adguard confessor-adguard added this to the 6.1 milestone Jun 24, 2016
@confessor-adguard confessor-adguard self-assigned this Jun 24, 2016
@BooBerry
Copy link

Will this also address the issue posted in this topic today?

https://forum.adguard.com/index.php?threads/jquerify.11361/

@ameshkov
Copy link
Member

ameshkov commented Jun 30, 2016

@confessor-adguard some notes on this:

  1. You currently wrap every JS rule into a try-catch statement. It would be better if you have on try-catch statement for all rules.
  2. It makes sense execute JS rules from an anonymous function:
(function() {
    try {
       JS rules go here
    } catch (ex) {
        // handle errors    
    }
})();
  1. We should implement some simple and lightweight jquery-like api functions to be used inside the JS rules. Like AG_onLoad and such. Let's ask @Alex-302 which functions do he need in this API.

As I understand here is a list of must-have functions.

  1. window load handler (like AG_onLoad)
$(function() { /* here goes the code */ });
  1. simple function to remove elements by selector:
$('someelement').remove();
  1. closest parent selector:
$('element').closest('div')
  1. children selector:
$('element').find('selector')

Just to give you an idea:
https://github.com/finom/balalaika

@ameshkov ameshkov reopened this Jun 30, 2016
@ameshkov
Copy link
Member

@confessor-adguard improve userscripts:

  1. Add comments to the important functions
  2. Change naming (no underscores)
  3. Do not copy deprecated properties (like those with webkit* prefix)

@BooBerry
Copy link

BooBerry commented Jun 30, 2016

Is there any Greasemonkey metadata blocks that Adguard doesn't support yet, where it could also be improved for compatibility reasons? Example being @run-at document-idle which was introduced in Greasemonkey 3.6. There's also Chrome/Safari-specific changes in the Tampermonkey API to look over and consider, I'm thinking.

@ameshkov
Copy link
Member

ameshkov commented Jul 4, 2016

@BooBerry nice, thanks for noting these!

@ameshkov
Copy link
Member

@confessor-adguard please note that in IE10 the limits situation has changed.

The limits were increased in IE 10 to the following:

A sheet may contain up to 65534 rules
A document may use up to 4095 stylesheets
@import nesting is limited to 4095 levels (due to the 4095 stylesheet limit)

We should take this into account.

@confessor-adguard
Copy link
Author

Partially fixed.
Moved to the next milestone.

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

No branches or pull requests

3 participants