mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-24 06:59:52 +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_'):
|
def __init__(self, rewriter, rules=[], prefix='WB_wombat_'):
|
||||||
rules = rules + [
|
rules = rules + [
|
||||||
# (r'(?<![/$])\blocation\b(?!\":)', RegexRewriter.add_prefix(prefix), 0),
|
# (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\.)domain', RegexRewriter.add_prefix(prefix), 0),
|
||||||
# (r'(?<=document\.)referrer', RegexRewriter.add_prefix(prefix), 0),
|
# (r'(?<=document\.)referrer', RegexRewriter.add_prefix(prefix), 0),
|
||||||
|
@ -1,34 +1,35 @@
|
|||||||
rules:
|
rules:
|
||||||
|
|
||||||
|
|
||||||
# twitter rules
|
# twitter rules
|
||||||
#=================================================================
|
#=================================================================
|
||||||
- url_prefix: 'com,twitter)/i/profiles/show/'
|
- url_prefix: 'com,twitter)/i/profiles/show/'
|
||||||
|
|
||||||
fuzzy_lookup: '/profiles/show/.*with_replies\?.*(max_id=[^&]+)'
|
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:
|
# rewrite:
|
||||||
js_rewrite_location: urls
|
# js_rewrite_location: urls
|
||||||
js_regexs:
|
# js_regexs:
|
||||||
- match: 'window.location'
|
# - match: 'window.location'
|
||||||
replace: 'window.WB_wombat_location'
|
# replace: 'window.WB_wombat_location'
|
||||||
|
|
||||||
- match: 'document.location'
|
# - match: 'document.location'
|
||||||
replace: 'document.WB_wombat_location'
|
# replace: 'document.WB_wombat_location'
|
||||||
|
|
||||||
#- url_prefix: 'com,twimg,ton)/'
|
#- url_prefix: 'com,twimg,ton)/'
|
||||||
|
|
||||||
# rewrite:
|
# rewrite:
|
||||||
# js_rewrite_location: all
|
# 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_rewrite_location: all
|
||||||
js_regexs:
|
# js_regexs:
|
||||||
- match: ';$'
|
# - 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()); }} }}) }} );'
|
# 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
|
# facebook rules
|
||||||
@ -168,17 +169,18 @@ rules:
|
|||||||
# vine
|
# vine
|
||||||
- url_prefix: 'co,vine,cdn,'
|
- url_prefix: 'co,vine,cdn,'
|
||||||
|
|
||||||
rewrite:
|
# rewrite:
|
||||||
js_rewrite_location: urls
|
# js_rewrite_location: urls
|
||||||
js_regexs:
|
# js_regexs:
|
||||||
- match: 'window.location'
|
# - match: 'window.location'
|
||||||
replace: 'WB_wombat_location'
|
# replace: 'WB_wombat_location'
|
||||||
|
|
||||||
fuzzy_lookup:
|
fuzzy_lookup:
|
||||||
replace: 'videos'
|
replace: 'videos'
|
||||||
match: 'videos(?:_[^/]+)?/([^?]+)'
|
match: 'videos(?:_[^/]+)?/([^?]+)'
|
||||||
|
|
||||||
# disqus
|
# disqus
|
||||||
|
#- url_prefix: ['com,disqus', 'com,disquscdn']
|
||||||
- url_prefix: 'com,disqus'
|
- url_prefix: 'com,disqus'
|
||||||
|
|
||||||
rewrite:
|
rewrite:
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user