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

Custom styles randomically neglected #37

Open
bunglegrind opened this issue Mar 6, 2020 · 6 comments
Open

Custom styles randomically neglected #37

bunglegrind opened this issue Mar 6, 2020 · 6 comments
Assignees
Labels

Comments

@bunglegrind
Copy link

bunglegrind commented Mar 6, 2020

Ok, another one:

page (not only this one...):
https://developer.wordpress.org/plugins/plugin-basics/determining-plugin-and-content-directories/

custom style:

#wpadminbar {
    display:none;
}
#wporg-header {
    display:none;
}
header {
    display:none;
}
#secondary {
    display:none;
}
#wporg-footer {
    display:none;
}
.breadcrumbs {
    display:none;
}
.nav-links {
    display:none;
}
.table-of-contents {
    display:none;
}
.toc-jump {
    display:none;
}
#content {
    max-width:100%!important;
}
.screen-reader-text {
    display:none;
}

In the epub at random I see some of the html classes/ids that I set to display:none (#wporg-header, #wporg-footer).

I've observed that in the HTML code of the preview shown by the browser (with alt+shift+1 for instance) the classes can be hidden or absent at all, in the former case the epub will show the aforementioned issue, in the latter the epub will be correctly displayed.

I've experienced this issue both with the latest release and with the master branch.

@alexadam alexadam self-assigned this Mar 6, 2020
@alexadam alexadam added the bug label Mar 6, 2020
@bunglegrind
Copy link
Author

Hi Adam, there is something in your code that I really don't get...possibly related to this issue.

In file extractHtml.js, it looks like lines 329-335 (which are related to the custom styles) are never executed...

@bunglegrind
Copy link
Author

It looks like Chrome is not affected...only Firefox

@alexadam
Copy link
Owner

alexadam commented Mar 6, 2020

hmm... that's the 'else' of the "Include (Custom) Style" check on the menu. it's a mess, I'll take a look on it

@bunglegrind
Copy link
Author

bunglegrind commented Mar 7, 2020

I see, I've tried to follow your code execution...and I think I found the bug.

I guess the problem is when you inject the custom css style in the page (chrome.tabs.insertCSS line 273 in background.js), you should wait until the operation is completed (in fact, the method accepts a callback, both in Firefox and Chrome, despite what is written in Firefox docs).

At the moment, you're not waiting - and probably this causes the issue in Firefox.

Anyway, I kindly suggest you to refactor your code in a more functional style, using map, filter, reduce to get rid of the for cycles, possibly resorting to a linter in order to mantain a strict adherence to a particular coding style and employing an asynchronous library, such as parseq (https://github.com/douglascrockford/parseq) or similar to remove all the callbacks. And you should remove the function parameters that are unused.

oh, and put the libraries you're using (jquery, etc.) in a lib folder or similar.

alexadam added a commit that referenced this issue Mar 9, 2020
@alexadam
Copy link
Owner

alexadam commented Mar 9, 2020

I fixed it, thanks for the help!

@bunglegrind
Copy link
Author

Very good!

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

2 participants