mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-15 00:03:28 +01:00
new wombat! refactor of rewriting:
- use defineProperty overrides on element prototypes - postMessage() rework: store actual origin with helper function __WB_pmw(window), from server side rewrite - Use window.URL (or external jsurl script) to override all properties of HTMLAnchorElement, override getAttribute() to return original - rename window -> $wbwindow
This commit is contained in:
parent
158b047897
commit
cee3c8cb61
@ -132,7 +132,9 @@ class JSLocationRewriterMixin(object):
|
||||
def __init__(self, rewriter, rules=[], prefix='WB_wombat_'):
|
||||
rules = rules + [
|
||||
# (r'(?<![/$])\blocation\b(?!\":)', RegexRewriter.add_prefix(prefix), 0),
|
||||
(r'(?<![/$\'"-])\blocation\b(?!(?:\":|=\d|-))', RegexRewriter.add_prefix(prefix), 0),
|
||||
(r'(?<![/$\'"-])\blocation\b(?!(?:\":|:|=\d|-))', RegexRewriter.add_prefix(prefix), 0),
|
||||
|
||||
(r'(?<=\.)postMessage\b\(', RegexRewriter.add_prefix('__WB_pmw(window).'), 0),
|
||||
|
||||
# (r'(?<=document\.)domain', RegexRewriter.add_prefix(prefix), 0),
|
||||
# (r'(?<=document\.)referrer', RegexRewriter.add_prefix(prefix), 0),
|
||||
|
@ -1,34 +1,35 @@
|
||||
rules:
|
||||
|
||||
|
||||
# twitter rules
|
||||
#=================================================================
|
||||
- url_prefix: 'com,twitter)/i/profiles/show/'
|
||||
|
||||
fuzzy_lookup: '/profiles/show/.*with_replies\?.*(max_id=[^&]+)'
|
||||
|
||||
- url_prefix: 'com,twimg,abs)/c/swift/en/bundle/boot'
|
||||
# - url_prefix: 'comx,twimg,abs)/c/swift/en/bundle/boot'
|
||||
|
||||
rewrite:
|
||||
js_rewrite_location: urls
|
||||
js_regexs:
|
||||
- match: 'window.location'
|
||||
replace: 'window.WB_wombat_location'
|
||||
# rewrite:
|
||||
# js_rewrite_location: urls
|
||||
# js_regexs:
|
||||
# - match: 'window.location'
|
||||
# replace: 'window.WB_wombat_location'
|
||||
|
||||
- match: 'document.location'
|
||||
replace: 'document.WB_wombat_location'
|
||||
# - match: 'document.location'
|
||||
# replace: 'document.WB_wombat_location'
|
||||
|
||||
#- url_prefix: 'com,twimg,ton)/'
|
||||
|
||||
# rewrite:
|
||||
# js_rewrite_location: all
|
||||
|
||||
- url_prefix: 'com,twimg,amp)/amplify-web-player/prod/js/build.min.js'
|
||||
# - url_prefix: 'comx,twimg,amp)/amplify-web-player/prod/js/build.min.js'
|
||||
|
||||
rewrite:
|
||||
# rewrite:
|
||||
#js_rewrite_location: all
|
||||
js_regexs:
|
||||
- match: ';$'
|
||||
replace: '; $(function() {{ var div = $(".poster-image")[0]; window._wb_wombat.watch_elem(div, function(elem) {{ if (elem.tagName == "IMG") {{ elem.setAttribute("width", $(div).width()); elem.setAttribute("height", $(div).height()); }} }}) }} );'
|
||||
# js_regexs:
|
||||
# - match: ';$'
|
||||
# replace: '; $(function() {{ var div = $(".poster-image")[0]; window._wb_wombat.watch_elem(div, function(elem) {{ if (elem.tagName == "IMG") {{ elem.setAttribute("width", $(div).width()); elem.setAttribute("height", $(div).height()); }} }}) }} );'
|
||||
|
||||
|
||||
# facebook rules
|
||||
@ -168,17 +169,18 @@ rules:
|
||||
# vine
|
||||
- url_prefix: 'co,vine,cdn,'
|
||||
|
||||
rewrite:
|
||||
js_rewrite_location: urls
|
||||
js_regexs:
|
||||
- match: 'window.location'
|
||||
replace: 'WB_wombat_location'
|
||||
# rewrite:
|
||||
# js_rewrite_location: urls
|
||||
# js_regexs:
|
||||
# - match: 'window.location'
|
||||
# replace: 'WB_wombat_location'
|
||||
|
||||
fuzzy_lookup:
|
||||
replace: 'videos'
|
||||
match: 'videos(?:_[^/]+)?/([^?]+)'
|
||||
|
||||
# disqus
|
||||
#- url_prefix: ['com,disqus', 'com,disquscdn']
|
||||
- url_prefix: 'com,disqus'
|
||||
|
||||
rewrite:
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user