mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-24 06:59:52 +01:00
wombat customization: pass custom options from config.yaml 'rewrite_opts.client' as a json obj
to wombat.js #96 currently supporting no_rewrite_prefixes, and skipping dom, setAttribute and postmessage overrides (used by via.hypothes.is) -- other options to be added later
This commit is contained in:
parent
2e4427100c
commit
74c6b60d5e
@ -99,6 +99,7 @@ class WbRequest(object):
|
|||||||
self.query_filter = []
|
self.query_filter = []
|
||||||
self.custom_params = {}
|
self.custom_params = {}
|
||||||
self.user_metadata = user_metadata
|
self.user_metadata = user_metadata
|
||||||
|
self.rewrite_opts = rewrite_opts
|
||||||
|
|
||||||
# PERF
|
# PERF
|
||||||
env['X_PERF'] = {}
|
env['X_PERF'] = {}
|
||||||
|
@ -31,6 +31,9 @@ _WBWombat = (function() {
|
|||||||
|
|
||||||
var wb_wombat_updating = false;
|
var wb_wombat_updating = false;
|
||||||
|
|
||||||
|
// custom options
|
||||||
|
var wb_opts;
|
||||||
|
|
||||||
//============================================
|
//============================================
|
||||||
function is_host_url(str) {
|
function is_host_url(str) {
|
||||||
// Good guess that's its a hostname
|
// Good guess that's its a hostname
|
||||||
@ -152,6 +155,13 @@ _WBWombat = (function() {
|
|||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OPTS: additional ignore prefixes
|
||||||
|
if (wb_opts.norewrite_prefixes) {
|
||||||
|
if (starts_with(url, wb_opts.no_rewrite_prefixes)) {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If starts with prefix, no rewriting needed
|
// If starts with prefix, no rewriting needed
|
||||||
// Only check replay prefix (no date) as date may be different for each
|
// Only check replay prefix (no date) as date may be different for each
|
||||||
// capture
|
// capture
|
||||||
@ -927,6 +937,8 @@ _WBWombat = (function() {
|
|||||||
function wombat_init(wbinfo) {
|
function wombat_init(wbinfo) {
|
||||||
wb_replay_prefix = wbinfo.prefix;
|
wb_replay_prefix = wbinfo.prefix;
|
||||||
|
|
||||||
|
wb_opts = wbinfo.wombat_opts || {};
|
||||||
|
|
||||||
if (wb_replay_prefix) {
|
if (wb_replay_prefix) {
|
||||||
wb_replay_date_prefix = wb_replay_prefix + wbinfo.wombat_ts + wbinfo.mod + "/";
|
wb_replay_date_prefix = wb_replay_prefix + wbinfo.wombat_ts + wbinfo.mod + "/";
|
||||||
|
|
||||||
@ -1019,7 +1031,10 @@ _WBWombat = (function() {
|
|||||||
init_open_override();
|
init_open_override();
|
||||||
|
|
||||||
// postMessage
|
// postMessage
|
||||||
init_postmessage_override();
|
// OPT skip
|
||||||
|
if (!wb_opts.skip_postmessage) {
|
||||||
|
init_postmessage_override();
|
||||||
|
}
|
||||||
|
|
||||||
// write
|
// write
|
||||||
init_write_override();
|
init_write_override();
|
||||||
@ -1032,8 +1047,9 @@ _WBWombat = (function() {
|
|||||||
init_mutation_obs();
|
init_mutation_obs();
|
||||||
|
|
||||||
// setAttribute
|
// setAttribute
|
||||||
init_setAttribute_override();
|
if (!wb_opts.skip_setAttribute) {
|
||||||
|
init_setAttribute_override();
|
||||||
|
}
|
||||||
// ensure namespace urls are NOT rewritten
|
// ensure namespace urls are NOT rewritten
|
||||||
init_createElementNS_fix();
|
init_createElementNS_fix();
|
||||||
|
|
||||||
@ -1044,7 +1060,10 @@ _WBWombat = (function() {
|
|||||||
init_cookies_override();
|
init_cookies_override();
|
||||||
|
|
||||||
// DOM
|
// DOM
|
||||||
init_dom_override();
|
// OPT skip
|
||||||
|
if (!wb_opts.skip_dom) {
|
||||||
|
init_dom_override();
|
||||||
|
}
|
||||||
|
|
||||||
// Random
|
// Random
|
||||||
init_seeded_random(wbinfo.wombat_sec);
|
init_seeded_random(wbinfo.wombat_sec);
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
wbinfo.wombat_host = "{{ urlsplit.netloc }}";
|
wbinfo.wombat_host = "{{ urlsplit.netloc }}";
|
||||||
wbinfo.wombat_sec = "{{ cdx.timestamp | format_ts('%s') }}";
|
wbinfo.wombat_sec = "{{ cdx.timestamp | format_ts('%s') }}";
|
||||||
|
|
||||||
wbinfo.wombat_opts = {{ wbrequest.rewrite_opts.client | tojson if wbrequest.rewrite_opts.client else 'undefined' }};
|
wbinfo.wombat_opts = {{ wbrequest.rewrite_opts.client | tojson if wbrequest.rewrite_opts.client else '{}' }};
|
||||||
|
|
||||||
if (window && window._WBWombat && !window._wb_js_inited) {
|
if (window && window._WBWombat && !window._wb_js_inited) {
|
||||||
var _wb_wombat = new _WBWombat(wbinfo);
|
var _wb_wombat = new _WBWombat(wbinfo);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user