mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2025-01-13 07:33:53 +08:00
.
This commit is contained in:
parent
b17943a3ac
commit
4f52269c7d
@ -2294,7 +2294,7 @@ class mdict(cishubase):
|
||||
return _type, file_content
|
||||
|
||||
if url.startswith("entry://"):
|
||||
return 3, "javascript:safe_mdict_entry_call('{}')".format(url[8:])
|
||||
return 3, "javascript:safe_mdict_search_word('{}')".format(url[8:])
|
||||
if url.startswith("sound://"):
|
||||
file_content = self.parse_url_in_mdd(index, url[8:])
|
||||
if not file_content:
|
||||
@ -2582,10 +2582,10 @@ for(let i=0;i<elements.length;i++)
|
||||
var lastmusicplayer=false;
|
||||
function mdict_play_sound(ext, b64){
|
||||
|
||||
if(window.mdict_audio_call)
|
||||
window.mdict_audio_call(b64)
|
||||
if(window.luna_audio_play_b64)
|
||||
window.luna_audio_play_b64(b64)
|
||||
else if(window.LUNAJSObject)
|
||||
window.LUNAJSObject.mdict_audio_call(b64)
|
||||
window.LUNAJSObject.luna_audio_play_b64(b64)
|
||||
else{
|
||||
const music = new Audio();
|
||||
music.src="data:"+ext+";base64,"+b64
|
||||
@ -2597,11 +2597,11 @@ if(window.mdict_audio_call)
|
||||
music.play();
|
||||
}
|
||||
}
|
||||
function safe_mdict_entry_call(word){
|
||||
if(window.mdict_entry_call)
|
||||
window.mdict_entry_call(word)
|
||||
function safe_mdict_search_word(word){
|
||||
if(window.luna_search_word)
|
||||
window.luna_search_word(word)
|
||||
else if(window.LUNAJSObject)
|
||||
window.LUNAJSObject.mdict_entry_call(word)
|
||||
window.LUNAJSObject.luna_search_word(word)
|
||||
}"""
|
||||
for varname, val in audiob64vals.items():
|
||||
func += '{}="{}"\n'.format(varname, val)
|
||||
|
@ -1,5 +1,5 @@
|
||||
import requests
|
||||
from urllib.parse import quote
|
||||
from urllib.parse import quote, unquote
|
||||
from cishu.cishubase import cishubase
|
||||
from myutils.utils import simplehtmlparser_all, simplehtmlparser
|
||||
import re, threading
|
||||
@ -42,6 +42,22 @@ class weblio(cishubase):
|
||||
|
||||
join = removeklass(join, "lgDictLg")
|
||||
join = removeklass(join, "lgDictSp")
|
||||
join = join.replace('href="//', 'href="https://')
|
||||
|
||||
def __(match):
|
||||
word = unquote(match.groups()[0])
|
||||
return '''href="javascript:safe_weblio_search_word('{}')"'''.format(word)
|
||||
|
||||
join = re.sub('href="https://www.weblio.jp/content/(.*?)"', __, join)
|
||||
join+=r'''
|
||||
<script>
|
||||
function safe_weblio_search_word(word){
|
||||
if(window.luna_search_word)
|
||||
window.luna_search_word(word)
|
||||
else if(window.LUNAJSObject)
|
||||
window.LUNAJSObject.luna_search_word(word)
|
||||
}</script>
|
||||
'''
|
||||
links = []
|
||||
style = simplehtmlparser(html, "style", "<style>")[7:-8]
|
||||
for link in simplehtmlparser_all(html, "link", '<link rel="stylesheet"'):
|
||||
|
@ -1265,10 +1265,10 @@ class searchwordW(closeashidewindow):
|
||||
functools.partial(globalconfig.__setitem__, "ZoomFactor")
|
||||
)
|
||||
self.textOutput.bind(
|
||||
"mdict_entry_call", lambda word: self.search_word.emit(word, False)
|
||||
"luna_search_word", lambda word: self.search_word.emit(word, False)
|
||||
)
|
||||
self.textOutput.bind(
|
||||
"mdict_audio_call",
|
||||
"luna_audio_play_b64",
|
||||
lambda b64: gobject.baseobject.audioplayer.play(
|
||||
base64.b64decode(b64.encode()), force=True
|
||||
),
|
||||
|
Loading…
x
Reference in New Issue
Block a user