From 755cf383a3f2af7185fcb80c0df86dba9e69fa4b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 20 Aug 2019 16:20:50 +0530 Subject: [PATCH] Only remove elements when doing a google dictionary search --- resources/lookup.js | 13 +++++++++---- src/calibre/gui2/viewer/lookup.py | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/resources/lookup.js b/resources/lookup.js index b86aadc8de..dd6e75b5ca 100644 --- a/resources/lookup.js +++ b/resources/lookup.js @@ -13,10 +13,15 @@ cc.style.marginLeft = '0'; cc = document.getElementById('cnt'); if (cc) cc.style.paddingTop = '0'; - ['sfcnt', 'top_nav', 'before-appbar', 'appbar', 'searchform', 'easter-egg'].forEach(function(id) { - var elem = document.getElementById(id); - if (elem) elem.style.display = 'none'; - }); + var params = new URLSearchParams(document.location.search.substring(1)); + var q = params.get('q'); + if (q && q.startsWith('define:')) { + 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'; + }); + } } if (window.location.hostname === 'www.google.com') fix_google_markup(); diff --git a/src/calibre/gui2/viewer/lookup.py b/src/calibre/gui2/viewer/lookup.py index 5c537fe80b..38b53d0920 100644 --- a/src/calibre/gui2/viewer/lookup.py +++ b/src/calibre/gui2/viewer/lookup.py @@ -23,13 +23,13 @@ from calibre.gui2.webengine import create_script, insert_scripts, secure_webengi vprefs.defaults['lookup_locations'] = [ { 'name': 'Google dictionary', - 'url': 'https://google.com/search?q=define:{word}', + 'url': 'https://www.google.com/search?q=define:{word}', 'langs': [], }, { 'name': 'Google search', - 'url': 'https://google.com/search?q={word}', + 'url': 'https://www.google.com/search?q={word}', 'langs': [], },