Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 04-16-2020, 05:36 PM   #16
iG0R
Enthusiast
iG0R began at the beginning.
 
Posts: 36
Karma: 10
Join Date: Apr 2020
Device: PC
Sorry, my bad, it has to be
Code:
if (window.location.hostname === 'www.google.com') {
    window.addEventListener('DOMContentLoaded', fix_google_markup());
}
to work properly.
iG0R is offline   Reply With Quote
Old 04-16-2020, 08:32 PM   #17
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 46,639
Karma: 169712392
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Quote:
Originally Posted by iG0R View Post
Hm, it's weird. Look at my screenshots.
I don't have any possibility to choose my account although I've already signed in my account in Chrome browser.
Also I found the following thread https://support.google.com/chrome/thread/31420989?hl=en
I wonder if this might be due to having a Chromium based browser (Microsoft's replacement for Edge) installed as well as Chrome and Firefox? I agree it is a bit weird.
DNSB is offline   Reply With Quote
Old 04-16-2020, 10:01 PM   #18
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,410
Karma: 27757236
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Quote:
Originally Posted by iG0R View Post
Sorry, my bad, it has to be
Code:
if (window.location.hostname === 'www.google.com') {
    window.addEventListener('DOMContentLoaded', fix_google_markup());
}
to work properly.
No, that's wrong. If you add () it means the function is called when the script is loaded instad of when the DOM is ready.
kovidgoyal is offline   Reply With Quote
Old 04-16-2020, 10:03 PM   #19
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,410
Karma: 27757236
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
And it works fine for me
Attached Thumbnails
Click image for larger version

Name:	lookup.png
Views:	101
Size:	389.9 KB
ID:	178464  
kovidgoyal is offline   Reply With Quote
Old 04-17-2020, 02:38 AM   #20
iG0R
Enthusiast
iG0R began at the beginning.
 
Posts: 36
Karma: 10
Join Date: Apr 2020
Device: PC
Quote:
Originally Posted by kovidgoyal View Post
No, that's wrong. If you add () it means the function is called when the script is loaded instad of when the DOM is ready.
Then without () it doesn't work for me leaving header and big margins as was abovementioned in my screenshot I'm using 4.13 version could it work properly in your case due to you utilize version with Python 3.x support?
iG0R is offline   Reply With Quote
Old 04-17-2020, 02:55 AM   #21
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,410
Karma: 27757236
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
I dont see how the python version would have any effect on javascript running inside the browser and it works for me with python 2 as well. it might be a timing issue since the google page is JS based as well. Try changing it to:

Code:
window.addEventListener('DOMContentLoaded', function() { setTimeout(fix_google_markup, 100); } );
kovidgoyal is offline   Reply With Quote
Old 04-17-2020, 03:00 AM   #22
iG0R
Enthusiast
iG0R began at the beginning.
 
Posts: 36
Karma: 10
Join Date: Apr 2020
Device: PC
Quote:
Originally Posted by kovidgoyal View Post
I dont see how the python version would have any effect on javascript running inside the browser and it works for me with python 2 as well. it might be a timing issue since the google page is JS based as well. Try changing it to:

Code:
window.addEventListener('DOMContentLoaded', function() { setTimeout(fix_google_markup, 100); } );
Still the same result even with 5000 - big margins and header.
iG0R is offline   Reply With Quote
Old 04-17-2020, 03:34 AM   #23
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,410
Karma: 27757236
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
right click on it open the inspect tool and see why its not working for you
kovidgoyal is offline   Reply With Quote
Old 04-17-2020, 05:39 PM   #24
iG0R
Enthusiast
iG0R began at the beginning.
 
Posts: 36
Karma: 10
Join Date: Apr 2020
Device: PC
Quote:
Originally Posted by kovidgoyal View Post
right click on it open the inspect tool and see why its not working for you
I've already tried it but after clicking "View page source" nothing happens the same as while clicking "Save page". Only working context menu's items are - Back, Forward, Reload, Zoom in, Zoom out, Default zoom.

Also I've tried to modify lookup.js to change CSS but faced with the strange results.
lookup.js:
Spoiler:
Code:
/* vim:fileencoding=utf-8
 * 
 * Copyright (C) 2019 Kovid Goyal <kovid at kovidgoyal.net>
 *
 * Distributed under terms of the GPLv3 license
 */

(function() {
    "use strict";

    function fix_google_markup() {
        var cc = document.getElementById('center_col');
        cc.style.marginLeft = '0';
        cc = document.getElementById('cnt');
        if (cc) cc.style.paddingTop = '0';
        var params = new URLSearchParams(document.location.search.substring(1));
        var q = params.get('q');
        if (q && q.startsWith('define:')) {
            cc.style.position = 'absolute';
            cc.style.top = '0';
            cc.style.left = '0';
            var remove = ['sfcnt', 'top_nav', 'before-appbar', 'appbar', 'searchform', 'easter-egg'];
            remove.forEach(function(id) {
                var elem = document.getElementById(id);
                if (elem) elem.style.display = 'none';
            });
        }
        var promo = document.getElementById('promos');
        if (promo) promo.parentNode.removeChild(promo);
    }

        var css = [
	"* {",
	"background-color: #fef3df !important;",
	"color: black !important;",
//	"border-color: #fef3df !important;",
	"}"
	].join("\n");

/*Block#1*/
	if (typeof GM_addStyle != "undefined") {
		GM_addStyle(css);
	} else if (typeof PRO_addStyle != "undefined") {
		PRO_addStyle(css);
	} else if (typeof addStyle != "undefined") {
		addStyle(css);
	} else {
		var node = document.createElement("style");
		node.type = "text/css";
		node.appendChild(document.createTextNode(css));
		var heads = document.getElementsByTagName("head");
		if (heads.length > 0) {
			heads[0].appendChild(node);
		} else {
			// no head yet, stick it whereever
			document.documentElement.appendChild(node);
		}
	}
/*End#1*/

	if (window.location.hostname === 'www.google.com' || window.location.hostname === 'translate.google.com') {
        window.addEventListener('DOMContentLoaded', function() { setTimeout(fix_google_markup, 5000); } );
/*Block#2*/
//		if (typeof GM_addStyle != "undefined") {
//			GM_addStyle(css);
//		} else if (typeof PRO_addStyle != "undefined") {
//			PRO_addStyle(css);
//		} else if (typeof addStyle != "undefined") {
//			addStyle(css);
//		} else {
//			var node = document.createElement("style");
//			node.type = "text/css";
//			node.appendChild(document.createTextNode(css));
//			var heads = document.getElementsByTagName("head");
//			if (heads.length > 0) {
//				heads[0].appendChild(node);
//			} else {
//				// no head yet, stick it whereever
//				document.documentElement.appendChild(node);
//			}
//		}
/*End#2*/
	}

/*Block#3*/	
//	if (typeof GM_addStyle != "undefined") {
//		GM_addStyle(css);
//	} else if (typeof PRO_addStyle != "undefined") {
//		PRO_addStyle(css);
//	} else if (typeof addStyle != "undefined") {
//		addStyle(css);
//	} else {
//		var node = document.createElement("style");
//		node.type = "text/css";
//		node.appendChild(document.createTextNode(css));
//		var heads = document.getElementsByTagName("head");
//		if (heads.length > 0) {
//			heads[0].appendChild(node);
//		} else {
//			// no head yet, stick it whereever
//			document.documentElement.appendChild(node);
//		}
//	}
/*End#3*/


})();


Blocks #2 and #3 don't work for 'translate.google.com', i.e. Google Translate aren't changing at all - as it was "white" it still remains "white". But for 'www.google.com' all Blocks (#1, #2, #3) work perfect.
iG0R is offline   Reply With Quote
Old 04-17-2020, 05:51 PM   #25
iG0R
Enthusiast
iG0R began at the beginning.
 
Posts: 36
Karma: 10
Join Date: Apr 2020
Device: PC
I tried your latest commit
Code:
        if (!cc) {
            if (++num_tries > 10) return;
            setTimeout(fix_google_markup, 100);
            return;
        }
but result still the same - big margins and presence of header.
iG0R is offline   Reply With Quote
Old 04-17-2020, 10:45 PM   #26
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,410
Karma: 27757236
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
There is an inspect entry in the menu which you should use, at least there is one if you are actually running from source. https://manual.calibre-ebook.com/develop.html
kovidgoyal is offline   Reply With Quote
Old 04-18-2020, 09:20 PM   #27
iG0R
Enthusiast
iG0R began at the beginning.
 
Posts: 36
Karma: 10
Join Date: Apr 2020
Device: PC
Quote:
Originally Posted by kovidgoyal View Post
There is an inspect entry in the menu which you should use, at least there is one if you are actually running from source. https://manual.calibre-ebook.com/develop.html
I get it. I didn't run Calibre from source, was hoping to get off easy.
iG0R is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
E-book viewer: clicking on image to evoke "View image" window. iG0R Calibre 12 04-15-2020 07:39 AM
Lost comments in "book details" window tcreek Library Management 5 06-23-2018 05:36 PM
Cannot dock "Book Browser" window [SOLVED] Dr. Drib Sigil 4 06-25-2013 04:12 PM
"No hack" comic book viewer on ALL eink kindles! geekmaster Kindle Developer's Corner 36 05-18-2012 10:53 AM
E-book Viewer Updates "Date Modified" on File. Why? spedinfargo Calibre 3 02-28-2011 05:24 PM


All times are GMT -4. The time now is 06:54 PM.


MobileRead.com is a privately owned, operated and funded community.