Enhance capture functionality to allow saving images regardless of domain filter when image capture is enabled
This commit is contained in:
@@ -45,7 +45,7 @@ def main():
|
||||
parser.add_argument('--capture', action='store_true', help='Capture XHR/fetch requests and responses while the browser is open')
|
||||
parser.add_argument('--capture-output', default='xhr_captured', help='Directory to save captured XHRs')
|
||||
parser.add_argument('--capture-wait', type=float, default=6.0, help='Seconds to wait after reload for XHRs to complete when capture starts')
|
||||
parser.add_argument('--capture-types', default='xhr,fetch,document', help='Comma-separated list of resource types to capture (e.g. xhr,fetch,document,image)')
|
||||
parser.add_argument('--capture-types', default='xhr,fetch,document,image', help='Comma-separated list of resource types to capture (e.g. xhr,fetch,document,image)')
|
||||
args = parser.parse_args()
|
||||
|
||||
os.makedirs(args.profile, exist_ok=True)
|
||||
@@ -98,10 +98,18 @@ def main():
|
||||
logger.debug(f'Response: {resp.status} {resp.url}')
|
||||
try:
|
||||
req = resp.request
|
||||
rtype = req.resource_type
|
||||
if args.domain not in req.url:
|
||||
return
|
||||
if rtype not in capture_types:
|
||||
rtype = (req.resource_type or '').lower()
|
||||
|
||||
# Save images regardless of domain filter when image capture is enabled.
|
||||
if rtype == 'image' and 'image' in capture_types:
|
||||
allow_save = True
|
||||
else:
|
||||
# For non-image responses, enforce domain filter
|
||||
if args.domain and args.domain not in req.url:
|
||||
return
|
||||
allow_save = rtype in capture_types
|
||||
|
||||
if not allow_save:
|
||||
return
|
||||
|
||||
ts = datetime.now(timezone.utc).strftime('%Y%m%dT%H%M%SZ')
|
||||
|
||||
Reference in New Issue
Block a user