26 мая 2021 г.

Network Filter expressions in Chrome DevTools


KeywordExample
cookie-domain:cookie-domain:.google.com
cookie-name:
cookie-path:cookie-path:/images
cookie-value:
domain:domain:*.com domain:example.com
has-response-header:has-response-header:Access-Control-Allow-Origin
is:is:from-cache is:service-worker-intercepted
larger-than:larger-than:10k
method:method:POST
mime-type:mime-type:application/json
mixed-content:
priority:priority:Highest
resource-type:resource-type:image resource-type:other
scheme:scheme:https
set-cookie-domain:set-cookie-domain:.google.com
set-cookie-name:set-cookie-name:__utma
set-cookie-value:set-cookie-value:abc123
status-code:status-code:204
url:url:data:

To invert the rule, i.e. leave URLs that do not match, prepend it with minus sign, e.g. -is:from-cache means "all resources loaded not from cache".

Any other text leaves only URLs with that text somewhere in it (in path, query, etc.)

Examples:

  • larger-than:10k resource-type:image -domain:*.net
    "all images not from *.net larger than 10 kilobytes"
  • is:from-cache resource-type:script
    "cached scripts"

19 февр. 2021 г.

Create IFRAME from string


<body>
<script>
  function makeURL(str) {
    var blob = new Blob([str], { type: "text/html" });
    return URL.createObjectURL(blob);
  }
  var ifr = document.createElement("iframe");
  ifr.src = makeURL('<button onclick="parent.navigate()">Click me</button>');
  document.body.appendChild(ifr);
  var oldTiming;
  function navigate() {
    oldTiming = frames[0].performance.navigation;
    ifr.src = makeURL('<button onclick="parent.doReload()">Now click me</button>');
  }
  function doReload() {
    ifr.onload = function() { alert(oldTiming.type + " " + frames[0].performance.navigation.type); }
    frames[0].location.reload();
  }
</script>