calibre/src/pyj/read_book/extract.pyj
2019-09-13 09:12:33 +05:30

16 lines
618 B
Plaintext

# vim:fileencoding=utf-8
# License: GPL v3 Copyright: 2019, Kovid Goyal <kovid at kovidgoyal.net>
from __python__ import bound_methods, hash_literals
def get_elements(x, y):
nonlocal img_id_counter
ans = {'link': None, 'img': None}
for elem in document.elementsFromPoint(x, y):
if elem.tagName.toLowerCase() is 'a' and elem.getAttribute('href') and not ans.link:
ans.link = elem.getAttribute('href')
elif elem.tagName.toLowerCase() is 'img' and elem.getAttribute('data-calibre-src') and not ans.img:
ans.img = elem.getAttribute('data-calibre-src')
return ans