Skip to content

Instantly share code, notes, and snippets.

@Sg4Dylan
Last active September 12, 2023 15:09
Show Gist options
  • Save Sg4Dylan/e8b28630a6b0bf27a1c1d873d58c0279 to your computer and use it in GitHub Desktop.
Save Sg4Dylan/e8b28630a6b0bf27a1c1d873d58c0279 to your computer and use it in GitHub Desktop.
bookwalker.com.tw online reader DRM
/**
Open Source Software Licenses
PUBLUS
Copyright(c) 2013-2014 ACCESS CO., LTD. All rights reserved.
This software includes all or part of the following open source software which is available under each license terms and conditions as follows:
* LAB.js (LABjs :: Loading And Blocking JavaScript)
v2.0.3 (c) Kyle Simpson
MIT License
*/
!function(a) {
function b(a) {
return "[object Function]" == Object.prototype.toString.call(a)
}
function c(a) {
return "[object Array]" == Object.prototype.toString.call(a)
}
function d(a, b) {
var c = /^\w+\:\/\//;
return /^\/\/\/?/.test(a) ? a = location.protocol + a : c.test(a) || "/" == a.charAt(0) || (a = (b || "") + a),
c.test(a) ? a : ("/" == a.charAt(0) ? r : q) + a
}
function e(a, b) {
for (var c in a)
a.hasOwnProperty(c) && (b[c] = a[c]);
return b
}
function f(a) {
for (var b = !1, c = 0; c < a.scripts.length; c++)
a.scripts[c].ready && a.scripts[c].exec_trigger && (b = !0,
a.scripts[c].exec_trigger(),
a.scripts[c].exec_trigger = null);
return b
}
function g(a, b, c, d) {
a.onload = a.onreadystatechange = function() {
a.readyState && "complete" != a.readyState && "loaded" != a.readyState || b[c] || (a.onload = a.onreadystatechange = null,
d())
}
}
function h(a) {
a.ready = a.finished = !0;
for (var b = 0; b < a.finished_listeners.length; b++)
a.finished_listeners[b]();
a.ready_listeners = [],
a.finished_listeners = []
}
function i(a, b, c, d, e) {
setTimeout(function() {
var f, h, i = b.real_src;
if ("item"in s) {
if (!s[0])
return void setTimeout(arguments.callee, 25);
s = s[0]
}
f = document.createElement("script"),
b.type && (f.type = b.type),
b.charset && (f.charset = b.charset),
e ? w ? (c.elem = f,
v ? (f.preload = !0,
f.onpreload = d) : f.onreadystatechange = function() {
"loaded" == f.readyState && d()
}
,
f.src = i) : e && 0 == i.indexOf(r) && a[l] ? (h = new XMLHttpRequest,
h.onreadystatechange = function() {
4 == h.readyState && (h.onreadystatechange = function() {}
,
c.text = h.responseText + "\n//@ sourceURL=" + i,
d())
}
,
h.open("GET", i),
h.send()) : (f.type = "text/cache-script",
g(f, c, "ready", function() {
s.removeChild(f),
d()
}),
f.src = i,
s.insertBefore(f, s.firstChild)) : x ? (f.async = !1,
g(f, c, "finished", d),
f.src = i,
s.insertBefore(f, s.firstChild)) : (g(f, c, "finished", d),
f.src = i,
s.insertBefore(f, s.firstChild))
}, 0)
}
function j() {
function q(a, b, c) {
function d() {
null != e && (e = null,
h(c))
}
var e;
A[b.src].finished || (a[n] || (A[b.src].finished = !0),
e = c.elem || document.createElement("script"),
b.type && (e.type = b.type),
b.charset && (e.charset = b.charset),
g(e, c, "finished", d),
c.elem ? c.elem = null : c.text ? (e.onload = e.onreadystatechange = null,
e.text = c.text) : e.src = b.real_src,
s.insertBefore(e, s.firstChild),
c.text && d())
}
function r(a, b, c, e) {
var f, g, j = function() {
b.ready_cb(b, function() {
q(a, b, f)
})
}, k = function() {
b.finished_cb(b, c)
};
b.src = d(b.src, a[p]),
b.real_src = b.src + (a[o] ? (/\?.*$/.test(b.src) ? "&_" : "?_") + ~~(1e9 * Math.random()) + "=" : ""),
A[b.src] || (A[b.src] = {
items: [],
finished: !1
}),
g = A[b.src].items,
a[n] || 0 == g.length ? (f = g[g.length] = {
ready: !1,
finished: !1,
ready_listeners: [j],
finished_listeners: [k]
},
i(a, b, f, e ? function() {
f.ready = !0;
for (var a = 0; a < f.ready_listeners.length; a++)
f.ready_listeners[a]();
f.ready_listeners = []
}
: function() {
h(f)
}
, e)) : (f = g[0],
f.finished ? k() : f.finished_listeners.push(k))
}
function t() {
function a(a, b) {
a.ready = !0,
a.exec_trigger = b,
g()
}
function d(a, b) {
a.ready = a.finished = !0,
a.exec_trigger = null;
for (var c = 0; c < b.scripts.length; c++)
if (!b.scripts[c].finished)
return;
b.finished = !0,
g()
}
function g() {
for (; n < l.length; )
if (b(l[n]))
try {
l[n++]()
} catch (a) {}
else {
if (!l[n].finished) {
if (f(l[n]))
continue;
break
}
n++
}
n == l.length && (o = !1,
j = !1)
}
function h() {
j && j.scripts || l.push(j = {
scripts: [],
finished: !0
})
}
var i, j, k = e(v, {}), l = [], n = 0, o = !1;
return i = {
script: function() {
for (var f = 0; f < arguments.length; f++)
!function(f, g) {
var l;
c(f) || (g = [f]);
for (var n = 0; n < g.length; n++)
h(),
f = g[n],
b(f) && (f = f()),
f && (c(f) ? (l = [].slice.call(f),
l.unshift(n, 1),
[].splice.apply(g, l),
n--) : ("string" == typeof f && (f = {
src: f
}),
f = e(f, {
ready: !1,
ready_cb: a,
finished: !1,
finished_cb: d
}),
j.finished = !1,
j.scripts.push(f),
r(k, f, j, x && o),
o = !0,
k[m] && i.wait()))
}(arguments[f], arguments[f]);
return i
},
wait: function() {
if (arguments.length > 0) {
for (var a = 0; a < arguments.length; a++)
l.push(arguments[a]);
j = l[l.length - 1]
} else
j = !1;
return g(),
i
}
},
{
script: i.script,
wait: i.wait,
setOptions: function(a) {
return e(a, k),
i
}
}
}
var u, v = {}, x = w || y, z = [], A = {};
return v[l] = !0,
v[m] = !1,
v[n] = !1,
v[o] = !1,
v[p] = "",
u = {
setGlobalDefaults: function(a) {
return e(a, v),
u
},
setOptions: function() {
return t().setOptions.apply(null, arguments)
},
script: function() {
return t().script.apply(null, arguments)
},
wait: function() {
return t().wait.apply(null, arguments)
},
queueScript: function() {
return z[z.length] = {
type: "script",
args: [].slice.call(arguments)
},
u
},
queueWait: function() {
return z[z.length] = {
type: "wait",
args: [].slice.call(arguments)
},
u
},
runQueue: function() {
for (var a, b = u, c = z.length, d = c; --d >= 0; )
a = z.shift(),
b = b[a.type].apply(null, a.args);
return b
},
noConflict: function() {
return a.$LAB = k,
u
},
sandbox: function() {
return j()
}
}
}
var k = a.$LAB
, l = "UseLocalXHR"
, m = "AlwaysPreserveOrder"
, n = "AllowDuplicates"
, o = "CacheBust"
, p = "BasePath"
, q = /^[^?#]*\//.exec(location.href)[0]
, r = /^\w+\:\/\/\/?[^\/]+/.exec(q)[0]
, s = document.head || document.getElementsByTagName("head")
, t = a.opera && "[object Opera]" == Object.prototype.toString.call(a.opera) || "MozAppearance"in document.documentElement.style
, u = document.createElement("script")
, v = "boolean" == typeof u.preload
, w = v || u.readyState && "uninitialized" == u.readyState
, x = !w && u.async === !0
, y = !w && !x && !t;
a.$LAB = j(),
function(a, b, c) {
null == document.readyState && document[a] && (document.readyState = "loading",
document[a](b, c = function() {
document.removeEventListener(b, c, !1),
document.readyState = "complete"
}
, !1))
}("addEventListener", "DOMContentLoaded")
}(this),
function() {
"use strict";
this.NFBR = {}
}
.call(this),
function() {
"use strict";
var a = ["../lib/jquery-1.8.0.custom.js", "../lib/jquery-ui-1.9.0.custom.js", "../lib/underscore.js", "../lib/backbone.js", "../lib/jquery.a0q.js", "../lib/parseuri.js", "../lib/jquery.touchSwipe.js", "../lib/jquery.cookie.js", "../lib/easyXDM.custom.js", "../lib/cldr.js", "../lib/globalize.js", "../lib/globalize-translate.js", "../lib/jquery.mousewheel.js", "../lib/jcarousellite.custom.js", "../lib/jquery.dotdotdot.js", "js/nfbr/util/device.js", "js/nfbr/base/config/config.js", "js/nfbr/config/config.js", "js/nfbr/external/external.js", "js/nfbr/util/key.js", "js/nfbr/util/xdr.js", "js/nfbr/util/corehttp.js", "js/nfbr/util/listenerhttp.js", "js/nfbr/util/http.js", "js/nfbr/util/blob.js", "js/nfbr/util/cache.js", "js/nfbr/util/content.js", "js/nfbr/util/a0q.js", "js/nfbr/util/drma0q.js", "js/nfbr/util/bina0q.js", "js/nfbr/util/display.js", "js/nfbr/util/window.js", "js/nfbr/util/url.js", "js/nfbr/util/resourcea0q.js", "js/nfbr/util/settings.js", "js/nfbr/util/calcdate.js", "js/nfbr/util/utf8.js", "js/nfbr/util/scrambler.js", "js/nfbr/util/image_loader.js", "js/nfbr/util/analytics.js", "js/nfbr/util/element_util.js", "js/nfbr/util/audio_player.js", "js/nfbr/server/server.js", "js/nfbr/book/book.js", "js/nfbr/book/bookmark.js", "js/nfbr/book/resume_data.js", "js/nfbr/book/bookmark_data.js", "js/nfbr/book/bookmark_resource.js", "js/nfbr/global/config.js", "js/nfbr/global/server.js", "js/nfbr/global/licheck.js", "js/nfbr/global/webapi.js", "js/nfbr/expublis/config.js", "js/nfbr/expublis/server.js", "js/nfbr/expublis/licheck.js", "js/nfbr/expublis/webapi.js", "js/nfbr/static/server.js", "js/nfbr/static/licheck.js", "js/nfbr/static/bookmark_resource.js", "js/nfbr/locale/config.js", "js/nfbr/locale/shared/supplemental.js", "js/nfbr/locale/lang/en.js", "js/nfbr/locale/lang/ja.js", "js/nfbr/viewer/lang/en.js", "js/nfbr/viewer/lang/ja.js", "js/nfbr/locale/locale.js", "js/nfbr/viewer/viewer.js", "js/nfbr/viewer/event.js", "js/nfbr/base/viewer/model.js", "js/nfbr/viewer/model.js", "js/nfbr/base/viewer/analytics/config.js", "js/nfbr/base/viewer/analytics/api.js", "js/nfbr/base/viewer/analytics/analyzer.js", "js/nfbr/viewer/analytics/analyzer.js", "js/nfbr/viewer/util.js", "js/nfbr/viewer/router.js", "js/nfbr/base/viewer/a6l.js", "js/nfbr/viewer/a6l.js", "js/nfbr/viewer/renderer.js", "js/nfbr/viewer/pageanimation.js", "js/nfbr/viewer/menu.js", "js/nfbr/viewer/page_slider.js", "js/nfbr/viewer/table_of_contents.js", "js/nfbr/viewer/table_of_bookmarks.js", "js/nfbr/viewer/settingPanel.js", "js/nfbr/viewer/end_of_book.js", "js/nfbr/viewer/content_progress.js", "js/nfbr/viewer/toc_image_list.js", "js/nfbr/viewer/viewport.js", "js/nfbr/viewer/message_dialog.js", "js/nfbr/viewer/status_dialog.js", "js/nfbr/viewer/resume_dialog.js", "js/nfbr/viewer/parameter.js", "js/nfbr/base/viewer/initialize.js", "js/nfbr/viewer/initialize.js", "js/nfbr/viewer/page_indicator.js", "js/nfbr/viewer/simple_message_dialog.js", "js/nfbr/viewer/popup_video_dialog.js", "js/nfbr/viewer/popup_web_dialog.js", "js/nfbr/viewer/extension_scheme_util.js", "js/nfbr_debug/util/analytics.js", "js/nfbr_debug/external/external.js", "js/nfbr_debug/viewer/parameter.js", "js/nfbr_debug/viewer/server.js", "js/nfbr_debug/book/bookmark_resource.js", "js/nfbr_debug/viewer/initialize.js"]
, b = ["../lib/readium/jquery-1.9.1.js", "../lib/readium/jquery-migrate-1.2.1.js", "../lib/readium/json2.js", "../lib/readium/underscore-1.4.4.js", "../lib/readium/backbone-0.9.10.js", "../lib/readium/URI-1.10.0.js", "../lib/readium/modernizr-2.5.3.min.js", "../lib/readium/bootstrap.min.js", "../lib/readium/dom_text_mapper.js", "../lib/readium/dom_text_matcher.js", "../lib/readium/range.js", "../lib/readium/text_match_engines.js", "../lib/readium/util.js", "../lib/readium/SimpleReadium_2328ee54915f39523a33125fa2b8f68383683c30.js", "../lib/jquery-ui-1.9.0.custom.js", "../lib/jquery.a0q.js", "../lib/parseuri.js", "../lib/jquery.touchSwipe.js", "../lib/jquery.cookie.js", "../lib/easyXDM.custom.js", "../lib/cldr.js", "../lib/globalize.js", "../lib/globalize-translate.js", "js/nfbr/util/device.js", "js/nfbr/base/config/config.js", "js/nfbr/readium/config/config.js", "js/nfbr/external/external.js", "js/nfbr/util/key.js", "js/nfbr/util/xdr.js", "js/nfbr/util/corehttp.js", "js/nfbr/util/listenerhttp.js", "js/nfbr/util/http.js", "js/nfbr/util/blob.js", "js/nfbr/util/cache.js", "js/nfbr/util/content.js", "js/nfbr/util/a0q.js", "js/nfbr/util/drma0q.js", "js/nfbr/util/bina0q.js", "js/nfbr/util/display.js", "js/nfbr/util/window.js", "js/nfbr/util/url.js", "js/nfbr/util/resourcea0q.js", "js/nfbr/util/settings.js", "js/nfbr/util/calcdate.js", "js/nfbr/util/utf8.js", "js/nfbr/util/scrambler.js", "js/nfbr/util/image_loader.js", "js/nfbr/readium/util/navigation_document.js", "js/nfbr/util/analytics.js", "js/nfbr/util/element_util.js", "js/nfbr/server/server.js", "js/nfbr/book/book.js", "js/nfbr/readium/book/book.js", "js/nfbr/book/bookmark.js", "js/nfbr/book/resume_data.js", "js/nfbr/book/bookmark_data.js", "js/nfbr/book/bookmark_resource.js", "js/nfbr/global/config.js", "js/nfbr/global/server.js", "js/nfbr/global/licheck.js", "js/nfbr/global/webapi.js", "js/nfbr/expublis/config.js", "js/nfbr/expublis/server.js", "js/nfbr/expublis/licheck.js", "js/nfbr/expublis/webapi.js", "js/nfbr/static/server.js", "js/nfbr/static/licheck.js", "js/nfbr/static/bookmark_resource.js", "js/nfbr/locale/config.js", "js/nfbr/locale/shared/supplemental.js", "js/nfbr/locale/lang/en.js", "js/nfbr/locale/lang/ja.js", "js/nfbr/viewer/lang/en.js", "js/nfbr/viewer/lang/ja.js", "js/nfbr/locale/locale.js", "js/nfbr/viewer/viewer.js", "js/nfbr/viewer/event.js", "js/nfbr/base/viewer/model.js", "js/nfbr/readium/viewer/model.js", "js/nfbr/base/viewer/analytics/config.js", "js/nfbr/base/viewer/analytics/api.js", "js/nfbr/base/viewer/analytics/analyzer.js", "js/nfbr/readium/viewer/analytics/analyzer.js", "js/nfbr/viewer/util.js", "js/nfbr/viewer/router.js", "js/nfbr/base/viewer/a6l.js", "js/nfbr/readium/viewer/a6l.js", "js/nfbr/viewer/pageanimation.js", "js/nfbr/viewer/menu.js", "js/nfbr/viewer/page_slider.js", "js/nfbr/viewer/table_of_contents.js", "js/nfbr/viewer/table_of_bookmarks.js", "js/nfbr/viewer/settingPanel.js", "js/nfbr/viewer/end_of_book.js", "js/nfbr/readium/viewer/content_progress.js", "js/nfbr/viewer/toc_image_list.js", "js/nfbr/viewer/viewport.js", "js/nfbr/viewer/message_dialog.js", "js/nfbr/viewer/status_dialog.js", "js/nfbr/viewer/resume_dialog.js", "js/nfbr/viewer/parameter.js", "js/nfbr/readium/viewer/custom_setting_panel.js", "js/nfbr/readium/viewer/custom_viewer.js", "js/nfbr/readium/viewer/page_slider.js", "js/nfbr/readium/viewer/menu.js", "js/nfbr/base/viewer/initialize.js", "js/nfbr/readium/viewer/initialize.js", "js/nfbr/viewer/page_indicator.js", "js/nfbr/viewer/simple_message_dialog.js", "js/nfbr/viewer/popup_video_dialog.js", "js/nfbr/viewer/popup_web_dialog.js", "js/nfbr/viewer/extension_scheme_util.js", "js/nfbr_debug/util/analytics.js", "js/nfbr_debug/external/external.js", "js/nfbr_debug/viewer/parameter.js", "js/nfbr_debug/viewer/server.js", "js/nfbr_debug/book/bookmark_resource.js", "js/nfbr_debug/viewer/initialize.js"];
NFBR.LoaderConfig = {
DEFAULT_ENGINE: "Auto",
VIEWER_ELEMENT: "#viewer",
REPLACED_ELEMENT: "#viewerReplaced",
engines: {
Image: {
SCRIPTS: ["js/viewer_image_0.1.8_2018-02-09.js", "./js/config.js"],
VIEWER_URL: "viewer_element.html"
},
Native: {
SCRIPTS: ["js/viewer_native_0.1.8_2018-02-09.js", "./js/config.js"],
VIEWER_URL: "viewer_element_readium.html",
VIEWER_CLASS: "native"
}
},
nativeIsSupported: function(a) {
return !1
},
getUserAgent_: function() {
return navigator.userAgent
},
isGalaxyS4DefaultBrowser_: function(a) {
return a.search(/Chrome/i) >= 0 && a.search(/Version/i) >= 0 && a.search(/SC-04E/i) >= 0
}
}
}
.call(this),
function() {
"use strict";
NFBR.Loader = function() {}
,
NFBR.Loader.EngineName = {
AUTO: "Auto",
IMAGE: "Image",
NATIVE: "Native"
},
NFBR.Loader.prototype = {
load: function() {
var a, b = this.parseQuery_(this.getQuery_()), c = b[NFBR.Loader.External.Key.DEFAULT_ENGINE];
a = c ? NFBR.LoaderConfig.engines[c] : NFBR.LoaderConfig.engines[NFBR.LoaderConfig.DEFAULT_ENGINE],
a || (a = NFBR.LoaderConfig.nativeIsSupported(b[NFBR.Loader.External.Key.CONTENT_TYPE]) ? NFBR.LoaderConfig.engines[NFBR.Loader.EngineName.NATIVE] : NFBR.LoaderConfig.engines[NFBR.Loader.EngineName.IMAGE]),
this.loadViewer_(a.SCRIPTS, NFBR.LoaderConfig.VIEWER_ELEMENT, NFBR.LoaderConfig.REPLACED_ELEMENT, a.VIEWER_URL, a.VIEWER_CLASS)
},
loadViewer_: function(a, b, c, d, e) {
var f, g = this;
this.enableDefaultTouchEvent_(!1);
var h = function() {
var a = $(c)
, f = $("<div></div>");
e && $(b).addClass(e),
f.load(d, function() {
a.replaceWith(f.children()),
NFBR.a6G.Initializer.initialize(),
g.enableDefaultTouchEvent_(!0)
})
};
f = 0;
var i = function() {
f < a.length ? ($LAB.script(a[f]).wait(i),
f++) : h()
};
i()
},
getQuery_: function() {
return window.location.search.slice(1)
},
parseQuery_: function(a) {
var b, c, e, f, g, h, i = a.split("&"), j = {};
for (b = 0; b < i.length; b++)
if (g = i[b].indexOf("="),
!(g < 0)) {
for (e = i[b].slice(0, g),
f = i[b].slice(g + 1),
h = null,
c = 0; c < d.length; c++)
if (d[c].key === e) {
h = d[c];
break
}
h && h.validate(f) && (j[e] = h.get(f))
}
return j
},
enableDefaultTouchEvent_: function(a) {
window.addEventListener && "ontouchstart"in window && (a ? (window.removeEventListener("touchstart", this.preventDefault_),
window.removeEventListener("touchmove", this.preventDefault_)) : (window.addEventListener("touchstart", this.preventDefault_, !1),
window.addEventListener("touchmove", this.preventDefault_, !1)))
},
preventDefault_: function(a) {
a.preventDefault()
}
},
NFBR.Loader.External = {
Key: {
DEFAULT_ENGINE: "den",
CONTENT_TYPE: "cty"
},
Engine: {
AUTO: 0,
IMAGE: 1,
NATIVE: 2
},
ContentType: {
EPUB: 0,
EPUB_PRE_PAGINATED: 1,
OMF: 2
}
};
var a = {}
, b = NFBR.Loader.External.Engine;
a[b.AUTO] = NFBR.Loader.EngineName.AUTO,
a[b.IMAGE] = NFBR.Loader.EngineName.IMAGE,
a[b.NATIVE] = NFBR.Loader.EngineName.NATIVE;
var c = NFBR.Loader.External.Key
, d = [{
key: c.DEFAULT_ENGINE,
get: function(b) {
return a[b]
},
validate: function(b) {
return "string" == typeof a[b]
},
isNullPermit: !1
}, {
key: c.CONTENT_TYPE,
get: function(a) {
return parseInt(a, 10)
},
validate: function(a) {
return "number" == typeof parseInt(a, 10)
},
isNullPermit: !1
}]
}
.call(this),
function() {
"use strict";
var a = new NFBR.Loader;
a.load()
}
.call(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment