mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Load lookup JS at document creation
This commit is contained in:
parent
42541ba212
commit
d0c5d21661
@ -29,5 +29,7 @@
|
|||||||
if (promo) promo.parentNode.removeChild(promo);
|
if (promo) promo.parentNode.removeChild(promo);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window.location.hostname === 'www.google.com') fix_google_markup();
|
if (window.location.hostname === 'www.google.com') {
|
||||||
|
window.addEventListener('DOMContentLoaded', fix_google_markup);
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
|
@ -14,7 +14,7 @@ from PyQt5.Qt import (
|
|||||||
QTimer, QUrl, QVBoxLayout, QWidget, pyqtSignal
|
QTimer, QUrl, QVBoxLayout, QWidget, pyqtSignal
|
||||||
)
|
)
|
||||||
from PyQt5.QtWebEngineWidgets import (
|
from PyQt5.QtWebEngineWidgets import (
|
||||||
QWebEnginePage, QWebEngineProfile, QWebEngineView
|
QWebEnginePage, QWebEngineProfile, QWebEngineScript, QWebEngineView
|
||||||
)
|
)
|
||||||
|
|
||||||
from calibre import prints, random_user_agent
|
from calibre import prints, random_user_agent
|
||||||
@ -193,7 +193,7 @@ def create_profile():
|
|||||||
ans.setHttpUserAgent(random_user_agent(allow_ie=False))
|
ans.setHttpUserAgent(random_user_agent(allow_ie=False))
|
||||||
ans.setCachePath(os.path.join(cache_dir(), 'ev2vl'))
|
ans.setCachePath(os.path.join(cache_dir(), 'ev2vl'))
|
||||||
js = P('lookup.js', data=True, allow_user_override=False)
|
js = P('lookup.js', data=True, allow_user_override=False)
|
||||||
insert_scripts(ans, create_script('lookup.js', js))
|
insert_scripts(ans, create_script('lookup.js', js, injection_point=QWebEngineScript.DocumentCreation))
|
||||||
s = ans.settings()
|
s = ans.settings()
|
||||||
s.setDefaultTextEncoding('utf-8')
|
s.setDefaultTextEncoding('utf-8')
|
||||||
create_profile.ans = ans
|
create_profile.ans = ans
|
||||||
|
Loading…
x
Reference in New Issue
Block a user