|
|
#1 |
|
Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 24
Karma: 1000010
Join Date: Jul 2015
Device: Kindle Paperwhite v1
|
Good evening and peace to everybody!
I know that MobileRead provides individual sub-fora with custom CSS rules and recipes both for Viewer and Calibre. Yet my request is a bit of a different kind. I regularly make CSS rules for various e-dictionaries powering one of my favourite browser apps, Lumetrium Definer. The main objective is to declutter the window view and focus on word and phrase definitions rather than ad blocking (which is a different beast on its own). I'm not a professional programmer, rather a happy, multi-lingual and CSS-savvy E-Viewer user. So would it be possible for me to apply / inject some CSS rules to the program's "Lookup/Search selected word [L]" section, for in its current form, dictionary webpages contain a lot of unnecessary divs and other HTML elements cluttering the view. I understand that it's not E-Viewer's fault per se, as it just provides a facility to link to external dictionary pages. Nevertheless, it makes working with the program unpleasant. I mean if there is an option I'm unaware of, I'll be happy to experiment with it on my own. Thank you! Rustam |
|
|
|
|
|
#2 |
|
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,981
Karma: 29579516
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
There is already code to cleanup google in the lookup panel. For other sites there isnt specific code, but you are welcome to contribute some. Basically write your code in lookup.js which you can find in the resources folder in the calibre installation. Override as described in: https://manual.calibre-ebook.com/cus...ates-et-cetera
|
|
|
|
|
|
#3 |
|
Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 24
Karma: 1000010
Join Date: Jul 2015
Device: Kindle Paperwhite v1
|
Thank you, Kovid! Glad to hear it is possible, you made my day!
![]() Analyzing lookup.js, I understand the rationale behind the code. That's indeed what I need. For overrides though, do I need to create a JavaScript file similar to `lookup.js` per dictionary? I've already created a resources directory under ~/.config/calibre (using Linux) but not sure what to do next. I have several dictionary sources I'd like to apply my CSS rules to. EDIT 1: I'll experiment with extending the existing JS code to accommodate CSS rules for another dictionary resource in the same file. And will report back... EDIT 2: I think I'm doing something wrong here, as the code fails to hide any HTML elements: https://pastebin.com/4LQVgcLH Rustam Last edited by simurq; 12-29-2025 at 02:31 PM. |
|
|
|
|
|
#4 |
|
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,981
Karma: 29579516
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
No there is one file loaded for all dictoinaries look at the bottom of the existing file you will see where it checks for google and applies its fixes only if the site being visited is google.
|
|
|
|
|
|
#5 |
|
Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 24
Karma: 1000010
Join Date: Jul 2015
Device: Kindle Paperwhite v1
|
Yes, I figured that part too, thank you anyway!
The style you see in the code is the same one used in the Firefox extension.
Last edited by simurq; 12-29-2025 at 02:40 PM. |
|
|
|
|
|
#6 |
|
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,981
Karma: 29579516
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
You can right click to open the inspector in the viewer than any console.log() calls from that script will show up there in the console tab.
|
|
|
|
|
|
#7 | |
|
Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 24
Karma: 1000010
Join Date: Jul 2015
Device: Kindle Paperwhite v1
|
I think the problem is Calibre doesn't load the modified JS file at all. As I said above, I placed lookup.js into ~/.config/calibre/resources. I even placed these commands at the very top of the file to test it:
Quote:
|
|
|
|
|
|
|
#8 |
|
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,981
Karma: 29579516
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Ah yes this one is not allowed to be overwritten there you go:
https://github.com/kovidgoyal/calibr...ab42cdcde9198e |
|
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Custom CSS Stylesheets for Calibre's Viewer | Ralob | Viewer | 393 | 11-08-2025 02:30 PM |
| Customize viewer css. pygments.css not found | drglenn | Viewer | 2 | 12-18-2020 05:52 PM |
| CSS rules ignored | thiago.eec | Viewer | 7 | 11-29-2020 10:04 PM |
| CSS Rules | deback | Conversion | 1 | 01-31-2019 04:59 PM |
| CSS rules | Sebastian Kane | Calibre | 1 | 07-19-2017 08:25 AM |