Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 30 additions & 31 deletions oex2nex/convertor.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
#"http://addons.opera.com/tools/oex_shim/"
shim_fetch_from = (u"https://cgit.oslo.osa/"
"cgi-bin/cgit.cgi/desktop/extensions/oex_shim/plain/build/")
oex_bg_shim = u"%s/operaextensions_background.js" % shim_dirname
oex_anypage_shim = u"%s/operaextensions_popup.js" % shim_dirname
oex_injscr_shim = u"%s/operaextensions_injectedscript.js" % shim_dirname
oex_bg_shim = u"%s/operaextensions_background.min.js" % shim_dirname
oex_anypage_shim = u"%s/operaextensions_popup.min.js" % shim_dirname
oex_injscr_shim = u"%s/000.operaextensions_injectedscript.min.js" % "includes"
oex_resource_loader = u"%s/popup_resourceloader" % shim_dirname
# TODO: add a smart way of adding these following default permissions
permissions = [u"http://*/*", u"https://*/*", u"storage"]
Expand Down Expand Up @@ -481,30 +481,29 @@ def _get_best_elem(_xmltree, tag):
if filename not in ["config.xml", indexdoc, popupdoc, optionsdoc]:
resources += ('"' + filename + '",')

if (filename != "config.xml"):
# Copy files from locales/en/ to root of the .nex package
do_copy = False
noloc_filename = None
if filename.startswith("locales/en"):
noloc_filename = re.sub(r'^locales/en[a-zA-Z-]{0,2}/', '',
filename, count=1)
if (noloc_filename != filename
and not (noloc_filename in zf_members)):
do_copy = True

# Copy files from locales/en/ to root of the .nex package
do_copy = False
noloc_filename = None
if filename.startswith("locales/en"):
noloc_filename = re.sub(r'^locales/en[a-zA-Z-]{0,2}/', '',
filename, count=1)
if (noloc_filename != filename
and not (noloc_filename in zf_members)):
do_copy = True

if noloc_filename and do_copy:
if debug:
print("Copying a localised file : "
"%s to the root of package as : %s" % (
filename, noloc_filename))
try:
nex.writestr(filename, file_data)
if noloc_filename and do_copy:
if debug:
print("Copying a localised file : "
"%s to the root of package as : %s" % (
filename, noloc_filename))
try:
nex.writestr(filename, file_data)
if noloc_filename and do_copy:
nex.writestr(noloc_filename, file_data)
except UnicodeEncodeError:
nex.writestr(filename, file_data.encode("utf-8"))
if noloc_filename and do_copy:
nex.writestr(noloc_filename, file_data.encode("utf-8"))
nex.writestr(noloc_filename, file_data)
except UnicodeEncodeError:
nex.writestr(filename, file_data.encode("utf-8"))
if noloc_filename and do_copy:
nex.writestr(noloc_filename, file_data.encode("utf-8"))

if has_injscrs:
if debug:
Expand Down Expand Up @@ -670,8 +669,8 @@ def _update_scopes(self, scriptdata):
try:
for key in rdict:
if 'text' in rdict[key] and 'textnew' in rdict[key]:
# NOTE: replaces throughout the script text; so be
# specific in what we feed this
# NOTE: replaces throughout the script text; so be
# specific in what we feed this
scriptdata = scriptdata.replace(rdict[key]['text'],
rdict[key]['textnew'])
except Exception as e:
Expand Down Expand Up @@ -938,9 +937,9 @@ def fetch_shims():
import urllib2
attempts = 0
shims = iter((
"operaextensions_background.js",
"operaextensions_popup.js",
"operaextensions_injectedscript.js",
"operaextensions_background.min.js",
"operaextensions_popup.min.js",
"operaextensions_injectedscript.min.js",
))
shim_dir = os.path.join(shim_fs_path, shim_dirname)
shim = next(shims)
Expand Down
39 changes: 39 additions & 0 deletions oex2nex/includes/000.operaextensions_injectedscript.min.js

Large diffs are not rendered by default.

Loading