XMLHttpRequest
requests that violate a single source policy . GM_xmlhttpRequest
, suggests that not all new standards are implemented in it (it’s hard to know whether you can get any type of response other than responseText
, in particular, whether the document is available as DOM- tree).XMLHttpRequest
queries.XMLHttpRequest
or properties of DOM elements. There is a brief introduction from the author . if (oSession.oRequest.headers.ExistsAndContains('Accept-Language', ',qya;q=0.001') && oSession.oRequest.headers.Exists('Origin')) { oSession.oResponse.headers['Access-Control-Allow-Origin'] = oSession.oRequest.headers['Origin']; oSession.oResponse.headers['Access-Control-Allow-Credentials'] = 'true'; if (oSession.oRequest.headers.Exists('Access-Control-Request-Method')) { oSession.oResponse.headers['Access-Control-Allow-Methods'] = oSession.oRequest.headers['Access-Control-Request-Method']; } if (oSession.oRequest.headers.Exists('Access-Control-Request-Headers')) { oSession.oResponse.headers['Access-Control-Allow-Headers'] = oSession.oRequest.headers['Access-Control-Request-Headers']; } if (oSession.oResponse.headers.Exists('Vary')) { oSession.oResponse.headers['Vary'] += ', Origin'; } else { oSession.oResponse.headers['Vary'] = 'Origin'; } }
c:\Users\[ ]\Documents\Fiddler2\Scripts\CustomRules.js
, see disaster recovery in the help or comments in the very beginning of the file). In the end, if you need to transfer your application to a person who will be afraid to edit the rule file himself, give him the finished one, already with an insert, and let him replace it at the right address.#fiddler--
). It will not work, since the hash is not sent via HTTP, it only makes sense for the browser (therefore, this method would be useful if we had to deal with the advanced extension of HTTP editing for the browser: it could intercept the hashes and change the headers based on this condition ( the mentioned Rewrite HTTP Headers (JS) can); if such an extension is ever developed with an implementation for all major browsers including Edge, you can think about this option).user:password@
with arbitrary strings in the hope that the server will ignore them. It turned out that browsers for some reason do not send this part via HTTP, it does not reach Fiddler. In addition, this part, as well as the port number, would still disappear during redirects, which for XMLHttpRequest
are transparent, without interception, and the exchange of headers with the new address would have already passed without Fiddler's participation.&fiddler=1
). It was found that some servers, finding an unfamiliar option in this part, are redirecting to a URL without this option. For such cases, it would be possible to add a marker, say, &&&
, which for the server would not be visible (when parsing would turn into three empty options and would not cause server concerns), but, again, if normal forwarding occurs, He will disappear from the address.X-Hello-Fiddler
). It turned out that the presence of such a header causes a so-called Preflighted request , which can be intercepted and edited, but if it is followed by a redirect, the browser will generally interrupt the request - Preflighted request with redirection is incompatible.Accept-Language
. It is configured by the browser according to the preferences of the preferred languages ​​in the browser options. You can get an idea of ​​them in JavaScript code using the navigator.languages ​​property, but it is not supported in IE11 (the navigator property supported by all browsers only gives the browser interface language). For example, in my three browsers, the JSON.stringify([navigator.language, navigator.languages])
code in the console displays the following: Chrome: "[ "en-US", [ "en-US", "en", "ru", "uk" ] ]" Firefox: "[ "en-US", [ "en-US", "en", "ru", "uk" ] ]" IE11: "[ "ru-RU", null ]"
Accept-Language
headers: Chrome: en-US,en;q=0.8,ru;q=0.6,uk;q=0.4 Firefox: en-US,en;q=0.8,ru;q=0.5,uk;q=0.3 IE11: en-US,en;q=0.8,ru;q=0.5,uk;q=0.3
qya
code. So, we need to add something like qya;q=0.001
to the header (the minimum number allowed by the standard), which we see in the very first checked condition for Fiddler a little higher (along with checking the Origin
header, which is a cross-domain query, - without it, there is no point in interfering with headlines, everything will work this way).Origin
request - without this, the browser will not give the answer to the script (when querying for local pages, it will be null
, but the server must return it);Access-Control-Allow-Credentials
- without this, the browser will not give access to the received information related to cookies, that is, you will not get the page that you get when you authorize on the site);Vary
header, without which the browser simply caches the response and will receive it from the cache, bypassing Fiddler, but it will come across another source in Access-Control-Allow-Origin
and terminate the request - the Vary
header will just put the caching such responses depending on the source of the request.XMLHttpRequest
requests). Firefox has an old bug that prevents even extensions from sending cookies if third-party cookies are not allowed in the browser settings. In IE, we have something similar. The P3P
rules are very complicated, not controlled by the user and interfered with them with the help of Fiddler. applications). However, there is an easy way out. In IE settings, you need to open these windows and check such options:XMLHttpRequest
requests for IE. By the way, I stumbled upon a strange glitch: after a single use of this option and the subsequent cancellation of it, IE still continued to send third-party cookies. Perhaps it was a unique set of circumstances.SEC7120: null Access-Control-Allow-Origin.
XMLHttpRequest: 0x80070005, .
null
( ). , null
, . , .Vary
Origin
), . , , ( ), — , : Chrome Firefox , IE11 . , .XMLHttpRequest
, CSP
(, Twitter GitHab). CSP
. ( CSP , , — ): if (/[?&]tempnocsp=1\b/i.test(oSession.PathAndQuery)) { oSession.oResponse.headers.Remove('Content-Security-Policy'); oSession.oResponse.headers.Remove('X-Content-Security-Policy'); }
tempnocsp=1
URL ( , ; , , — Fiddler-). : javascript:(function(l) { if (!/[?&]tempnocsp=1\b/i.test(l.href)) { l.href += (/\?/.test(l.href) ? "&" : "?") + "tempnocsp=1"; } })(location);
HEAD
, Content-Type
, Last-Modified
Content-Length
. , . , . responseURL
IE11 ( , , , Edge).Content-Type
Last-Modified
, Content-Length
. , Chrome :VM117:1 Refused to get unsafe header "Content-Length"
if (oSession.RequestMethod == 'HEAD') { if (oSession.oResponse.headers.Exists('Access-Control-Expose-Headers')) { oSession.oResponse.headers['Access-Control-Expose-Headers'] += ', Content-Length'; } else { oSession.oResponse.headers['Access-Control-Expose-Headers'] = 'Content-Length'; } }
if (oSession.oRequest.headers.ExistsAndContains('Accept-Language', ',qya;q=0.001') && oSession.oRequest.headers.Exists('Origin')) { oSession.oResponse.headers['Access-Control-Allow-Origin'] = oSession.oRequest.headers['Origin']; oSession.oResponse.headers['Access-Control-Allow-Credentials'] = 'true'; if (oSession.oRequest.headers.Exists('Access-Control-Request-Method')) { oSession.oResponse.headers['Access-Control-Allow-Methods'] = oSession.oRequest.headers['Access-Control-Request-Method']; } if (oSession.oRequest.headers.Exists('Access-Control-Request-Headers')) { oSession.oResponse.headers['Access-Control-Allow-Headers'] = oSession.oRequest.headers['Access-Control-Request-Headers']; } if (oSession.oResponse.headers.Exists('Vary')) { oSession.oResponse.headers['Vary'] += ', Origin'; } else { oSession.oResponse.headers['Vary'] = 'Origin'; } if (oSession.RequestMethod == 'HEAD') { if (oSession.oResponse.headers.Exists('Access-Control-Expose-Headers')) { oSession.oResponse.headers['Access-Control-Expose-Headers'] += ', Content-Length'; } else { oSession.oResponse.headers['Access-Control-Expose-Headers'] = 'Content-Length'; } } } if (/[?&]tempnocsp=1\b/i.test(oSession.PathAndQuery)) { oSession.oResponse.headers.Remove('Content-Security-Policy'); oSession.oResponse.headers.Remove('X-Content-Security-Policy'); }
javascript:(function(url, xhr) { if(!url) {return;} xhr = new XMLHttpRequest(); try {xhr.open('HEAD', url, true);} catch (e) { alert(e.name + ': ' + e.message); return; } xhr.setRequestHeader('Accept-Language', 'en-US,en;q=0.8,ru;q=0.6,uk;q=0.4,qya;q=0.001'); xhr.responseType = 'document'; xhr.timeout = 10000; xhr.withCredentials = true; xhr.onload = function(evt, l) { l = this.getResponseHeader('Content-Length'); alert([ this.responseURL || '?', this.getResponseHeader('Content-Type') || '?', this.getResponseHeader('Last-Modified') || '?', l ? [l + ' B', (l / 1024) .toFixed(3) + ' kB', (l / 1048576) .toFixed(3) + ' MB', (l / 1073741824).toFixed(3) + ' GB'].join(' \u2248 ') : '?' ].join('\n\n') + '\n\n'); }; xhr.ontimeout = xhr.onerror = function(evt) {alert(evt.type.charAt(0).toUpperCase() + evt.type.slice(1) + '.');}; try {xhr.send(null);} catch (e) {alert(e.name + ': ' + e.message); return;} })(document.activeElement.href || prompt('URL:'))
xhr.onerror
:XMLHttpRequest cannot load file:///... Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.
xhr.send()
, , , . :NS_ERROR_DOM_BAD_URI: Access to restricted URI denied
xhr.open()
. . IE :Error: .
XMLHttpRequest
. ( — ). javascript:(function(d, l, throbber, div, url, ar, arl, i, str, el, info_url, info_title){ if (d.activeElement.href) {l = d.activeElement;} else {l = location;} throbber = 'data:image/gif;base64,R0lGODlhEAAQAOMIAAAAABoaGjMzM0xMTGZmZoCAgJmZmbKysv///////////////////////////////yH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgAIACwAAAAAEAAQAAAESBDJiQCgmFqbZwjVhhwH9n3hSJbeSa1sm5GUIHSTYSC2jeu63q0D3PlwCB1lMMgUChgmk/J8LqUIAgFRhV6z2q0VF94iJ9pOBAAh+QQBCgAPACwAAAAAEAAQAAAESPDJ+UKgmFqbpxDV9gAA9n3hSJbeSa1sm5HUMHTTcTy2jeu63q0D3PlwDx2FQMgYDBgmk/J8LqWPQuFRhV6z2q0VF94iJ9pOBAAh+QQBCgAPACwAAAAAEAAQAAAESPDJ+YSgmFqb5xjV9gQB9n3hSJbeSa1sm5EUQXQTADy2jeu63q0D3PlwDx2lUMgcDhgmk/J8LqUPg+FRhV6z2q0VF94iJ9pOBAAh+QQBCgAPACwAAAAAEAAQAAAESPDJ+cagmFqbJyHV9ggC9n3hSJbeSa1sm5FUUXRTEDy2jeu63q0D3PlwDx3FYMgAABgmk/J8LqWPw+FRhV6z2q0VF94iJ9pOBAAh+QQBCgAPACwAAAAAEAAQAAAESPDJ+QihmFqbZynV9gwD9n3hSJbeSa1sm5GUYXSTIDy2jeu63q0D3PlwDx3lcMgEAhgmk/J8LqUPAOBRhV6z2q0VF94iJ9pOBAAh+QQBCgAPACwAAAAAEAAQAAAESPDJ+UqhmFqbpzHV9hAE9n3hSJbeSa1sm5HUcXTTMDy2jeu63q0D3PlwDx0FAMgIBBgmk/J8LqWPQOBRhV6z2q0VF94iJ9pOBAAh+QQBCgAPACwAAAAAEAAQAAAESPDJ+YyhmFqb5znV9hQF9n3hSJbeSa1sm5EUAHQTQTy2jeu63q0D3PlwDx0lEMgMBhgmk/J8LqUPgeBRhV6z2q0VF94iJ9pOBAAh+QQBCgAPACwAAAAAEAAQAAAESPDJ+c6hmFqbJwDV9hgG9n3hSJbeSa1sm5FUEHRTUTy2jeu63q0D3PlwDx1FIMgQCBgmk/J8LqWPweBRhV6z2q0VF94iJ9pOBAA7'; div = d.createElement('div'); div.setAttribute('data-breadcrumbs-main', ''); div.appendChild(d.createElement('style')).textContent=[ 'div[data-breadcrumbs-main] {position:fixed; top:0px; left:0; z-index:999999; width:100%; padding:10px !important; background-color:white !important; outline:1px solid black !important; font-size: 12pt !important; text-align: left !important;}', 'div[data-breadcrumbs-main] a {font-size: 12pt !important; text-decoration: underline !important;}', 'div[data-breadcrumbs-main] div {margin-top: 20px!important; color: silver !important;}', 'div[data-breadcrumbs-info-title] {background-repeat: no-repeat !important; background-position: left center !important; padding-left: 20px !important;}', ].join('\n'); url = l.protocol + (/:[/][/]/.test(l.href) ? '//' : ''); div.appendChild(d.createElement('span')).textContent = url; ar = l.hostname.split('.'); arl = ar.length; if(arl > 1) { ar.splice(arl - 2, 2, ar.slice(arl - 2).join('.')); arl--; } for (i = 0; i < arl; i++) { str = ar[i]; if (i > 0) {div.appendChild(d.createElement('span')).textContent = '.';} el = div.appendChild(d.createElement('a')); el.textContent = str; el.href = url + ar.slice(i).join('.'); } url += l.hostname; if(l.port && /:\d+$/.test(l.host)) { div.appendChild(d.createElement('span')).textContent = ':'; el = div.appendChild(d.createElement('a')); el.textContent = l.port; url += ':' + l.port; el.href = url; } div.appendChild(d.createElement('span')).textContent = '/'; url += '/'; if(l.pathname.length > 1){ ar = l.pathname.split('/'); ar.shift(); arl = ar.length; for (i = 0; i < arl; i++) { str = ar[i]; if (i < arl-1) { el = div.appendChild(d.createElement('a')); el.textContent = str; url += str; div.appendChild(d.createElement('span')).textContent = '/'; url += '/'; el.href = url; } else if (str !== '') { el = div.appendChild(d.createElement('a')); el.textContent = str; url += str; el.href = url; } } } if(l.search){ ar = l.search.split('&'); arl = ar.length; ar[0] = ar[0].substring(1); div.appendChild(d.createElement('span')).textContent = '?'; url += '?'; for (i = 0; i < arl; i++) { str = ar[i]; if (i > 0) { div.appendChild(d.createElement('span')).textContent = '&'; url += '&'; } el = div.appendChild(d.createElement('a')); el.textContent = str; url += str; el.href = url; } } if(l.hash){ div.appendChild(d.createElement('span')).textContent = '#'; el = div.appendChild(d.createElement('a')); el.textContent = l.hash.substring(1); url += l.hash; el.href = url; } if (div.querySelector('a:last-of-type').href == location.href) { div.querySelector('a:last-of-type').setAttribute('data-breadcrumbs-doc-title', d.title); } info_url = div.appendChild(d.createElement('div')); info_url.setAttribute('data-breadcrumbs-info-url', ''); info_url.textContent = 'URL'; info_title = div.appendChild(d.createElement('div')); info_title.setAttribute('data-breadcrumbs-info-title', ''); info_title.textContent = 'Title'; div.addEventListener('mouseover', function(evt, h, t){ if (h = evt.target.href) { info_url.textContent = h; if (t = evt.target.getAttribute('data-breadcrumbs-doc-title')) { info_title.textContent = t; } else{getTitle(evt.target);} } }); div.addEventListener('dblclick' /*mouseleave*/, function(){div.parentNode.removeChild(div);}); d.body.appendChild(div); function getTitle(lnk, xhr) { info_title.style.backgroundImage = 'url('+ throbber + ')'; xhr = new XMLHttpRequest(); try {xhr.open('GET', lnk.href, true);} catch (e) { info_title.style.backgroundImage = 'none'; info_title.textContent = e.name + ': ' + e.message; return; } xhr.setRequestHeader('Accept-Language', 'en-US,en;q=0.8,ru;q=0.6,uk;q=0.4,qya;q=0.001'); xhr.responseType = 'document'; xhr.timeout = 10000; xhr.withCredentials = true; xhr.onload = function() { info_title.style.backgroundImage = 'none'; if (this.response && this.response.title) { info_title.textContent = this.response.title; lnk.setAttribute('data-breadcrumbs-doc-title', this.response.title); } else { info_title.textContent = '?'; lnk.setAttribute('data-breadcrumbs-doc-title', '?'); } }; xhr.ontimeout = xhr.onerror = function(evt){ info_title.style.backgroundImage = 'none'; info_title.textContent = evt.type.charAt(0).toUpperCase() + evt.type.slice(1) + '.'; }; try {xhr.send(null);} catch (e) { info_title.style.backgroundImage = 'none'; info_title.textContent = e.name + ': ' + e.message; } } })(document)
CORS
. , . , MDN , : javascript:(function(e,t,n,a,A,i,r,o,l,p,d,s){function h(e,t){s.style.backgroundImage='url('+n+')',t=new XMLHttpRequest;try{t.open('GET',e.href,!0)}catch(a){return s.style.backgroundImage='none',void(s.textContent=a.name+': '+a.message)}t.setRequestHeader('Accept-Language','en-US,en;q=0.8,ru;q=0.6,uk;q=0.4,qya;q=0.001'),t.responseType='document',t.timeout=1e4,t.withCredentials=!0,t.onload=function(){s.style.backgroundImage='none',this.response&&this.response.title?(s.textContent=this.response.title,e.setAttribute('data-breadcrumbs-doc-title',this.response.title)):(s.textContent='?',e.setAttribute('data-breadcrumbs-doc-title','?'))},t.ontimeout=t.onerror=function(e){s.style.backgroundImage='none',s.textContent=e.type.charAt(0).toUpperCase()+e.type.slice(1)+'.'};try{t.send(null)}catch(a){s.style.backgroundImage='none',s.textContent=a.name+': '+a.message}}for(t=e.activeElement.href?e.activeElement:location,n='data:image/gif;base64,R0lGODlhEAAQAOMIAAAAABoaGjMzM0xMTGZmZoCAgJmZmbKysv///////////////////////////////yH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgAIACwAAAAAEAAQAAAESBDJiQCgmFqbZwjVhhwH9n3hSJbeSa1sm5GUIHSTYSC2jeu63q0D3PlwCB1lMMgUChgmk/J8LqUIAgFRhV6z2q0VF94iJ9pOBAAh+QQBCgAPACwAAAAAEAAQAAAESPDJ+UKgmFqbpxDV9gAA9n3hSJbeSa1sm5HUMHTTcTy2jeu63q0D3PlwDx2FQMgYDBgmk/J8LqWPQuFRhV6z2q0VF94iJ9pOBAAh+QQBCgAPACwAAAAAEAAQAAAESPDJ+YSgmFqb5xjV9gQB9n3hSJbeSa1sm5EUQXQTADy2jeu63q0D3PlwDx2lUMgcDhgmk/J8LqUPg+FRhV6z2q0VF94iJ9pOBAAh+QQBCgAPACwAAAAAEAAQAAAESPDJ+cagmFqbJyHV9ggC9n3hSJbeSa1sm5FUUXRTEDy2jeu63q0D3PlwDx3FYMgAABgmk/J8LqWPw+FRhV6z2q0VF94iJ9pOBAAh+QQBCgAPACwAAAAAEAAQAAAESPDJ+QihmFqbZynV9gwD9n3hSJbeSa1sm5GUYXSTIDy2jeu63q0D3PlwDx3lcMgEAhgmk/J8LqUPAOBRhV6z2q0VF94iJ9pOBAAh+QQBCgAPACwAAAAAEAAQAAAESPDJ+UqhmFqbpzHV9hAE9n3hSJbeSa1sm5HUcXTTMDy2jeu63q0D3PlwDx0FAMgIBBgmk/J8LqWPQOBRhV6z2q0VF94iJ9pOBAAh+QQBCgAPACwAAAAAEAAQAAAESPDJ+YyhmFqb5znV9hQF9n3hSJbeSa1sm5EUAHQTQTy2jeu63q0D3PlwDx0lEMgMBhgmk/J8LqUPgeBRhV6z2q0VF94iJ9pOBAAh+QQBCgAPACwAAAAAEAAQAAAESPDJ+c6hmFqbJwDV9hgG9n3hSJbeSa1sm5FUEHRTUTy2jeu63q0D3PlwDx1FIMgQCBgmk/J8LqWPweBRhV6z2q0VF94iJ9pOBAA7',a=e.createElement('div'),a.setAttribute('data-breadcrumbs-main',''),a.appendChild(e.createElement('style')).textContent='div[data-breadcrumbs-main] {position:fixed; top:0px; left:0; z-index:999999; width:100%; padding:10px !important; background-color:white !important; outline:1px solid black !important; font-size: 12pt !important; text-align: left !important;}\ndiv[data-breadcrumbs-main] a {font-size: 12pt !important; text-decoration: underline !important;}\ndiv[data-breadcrumbs-main] div {margin-top: 20px!important; color: silver !important;}\ndiv[data-breadcrumbs-info-title] {background-repeat: no-repeat !important; background-position: left center !important; padding-left: 20px !important;}',A=t.protocol+(/:[\/][\/]/.test(t.href)?'//':''),a.appendChild(e.createElement('span')).textContent=A,i=t.hostname.split('.'),r=i.length,r>1&&(i.splice(r-2,2,i.slice(r-2).join('.')),r--),o=0;r>o;o++)l=i[o],o>0&&(a.appendChild(e.createElement('span')).textContent='.'),p=a.appendChild(e.createElement('a')),p.textContent=l,p.href=A+i.slice(o).join('.');if(A+=t.hostname,t.port&&/:\d+$/.test(t.host)&&(a.appendChild(e.createElement('span')).textContent=':',p=a.appendChild(e.createElement('a')),p.textContent=t.port,A+=':'+t.port,p.href=A),a.appendChild(e.createElement('span')).textContent='/',A+='/',t.pathname.length>1)for(i=t.pathname.split('/'),i.shift(),r=i.length,o=0;r>o;o++)l=i[o],r-1>o?(p=a.appendChild(e.createElement('a')),p.textContent=l,A+=l,a.appendChild(e.createElement('span')).textContent='/',A+='/',p.href=A):''!==l&&(p=a.appendChild(e.createElement('a')),p.textContent=l,A+=l,p.href=A);if(t.search)for(i=t.search.split('&'),r=i.length,i[0]=i[0].substring(1),a.appendChild(e.createElement('span')).textContent='?',A+='?',o=0;r>o;o++)l=i[o],o>0&&(a.appendChild(e.createElement('span')).textContent='&',A+='&'),p=a.appendChild(e.createElement('a')),p.textContent=l,A+=l,p.href=A;t.hash&&(a.appendChild(e.createElement('span')).textContent='#',p=a.appendChild(e.createElement('a')),p.textContent=t.hash.substring(1),A+=t.hash,p.href=A),a.querySelector('a:last-of-type').href==location.href&&a.querySelector('a:last-of-type').setAttribute('data-breadcrumbs-doc-title',e.title),d=a.appendChild(e.createElement('div')),d.setAttribute('data-breadcrumbs-info-url',''),d.textContent='URL',s=a.appendChild(e.createElement('div')),s.setAttribute('data-breadcrumbs-info-title',''),s.textContent='Title',a.addEventListener('mouseover',function(e,t,n){(t=e.target.href)&&(d.textContent=t,(n=e.target.getAttribute('data-breadcrumbs-doc-title'))?s.textContent=n:h(e.target))}),a.addEventListener('dblclick',function(){a.parentNode.removeChild(a)}),e.body.appendChild(a)})(document)
sites
, . : CSS- , ; : ( ) , ( — ). <!doctype html> <html> <head> <meta charset='UTF-8'><title>User Data Aggregation</title> <style> body > div > a {display: inline-block; background-repeat: no-repeat;} body > div > pre, body > div > a {padding: 5px 5px 5px 20px; margin: 0px;} </style> <script> /******************************************************************************/ 'use strict'; /******************************************************************************/ var sites = { 'habrahabr.ru': { checkPageURL: 'http://habrahabr.ru/users/vmb/', keyElementSelectors: '#layout > div.inner > div.user_header > div.karma, #layout > div.inner > div.user_header > div.rating, #layout > div.inner > div.content_left > div.user_profile > div.rating-place, #layout > div.inner > div.sidebar_right > div.block.user_info > div.info', re: [ /(\d+) (\d+ .+)/, '$1 ($2)' ] }, 'geektimes.ru': { checkPageURL: 'http://geektimes.ru/users/vmb/', keyElementSelectors: '#layout > div.inner > div.user_header > div.karma, #layout > div.inner > div.user_header > div.rating, #layout > div.inner > div.content_left > div.user_profile > div.rating-place, #layout > div.inner > div.sidebar_right > div.block.user_info > div.info', re: [ /(\d+) (\d+ .+)/, '$1 ($2)' ] }, 'megamozg.ru': { checkPageURL: 'http://megamozg.ru/users/vmb/', keyElementSelectors: '#layout > div.inner > div.user_header > div.karma, #layout > div.inner > div.user_header > div.rating, #layout > div.inner > div.content_left > div.user_profile > div.rating-place, #layout > div.inner > div.sidebar_right > div.block.user_info > div.info', re: [ /(\d+) (\d+ .+)/, '$1 ($2)' ] }, 'toster.ru': { checkPageURL: 'https://toster.ru/user/vmb', keyElementSelectors: '#js-canvas > div.layout__body > section > div.column_main > main > header > div.page-header__stats > ul > li', }, }; /******************************************************************************/ var throbber = 'data:image/gif;base64,R0lGODlhEAAQAOMIAAAAABoaGjMzM0xMTGZmZoCAgJmZmbKysv///////////////////////////////yH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgAIACwAAAAAEAAQAAAESBDJiQCgmFqbZwjVhhwH9n3hSJbeSa1sm5GUIHSTYSC2jeu63q0D3PlwCB1lMMgUChgmk/J8LqUIAgFRhV6z2q0VF94iJ9pOBAAh+QQBCgAPACwAAAAAEAAQAAAESPDJ+UKgmFqbpxDV9gAA9n3hSJbeSa1sm5HUMHTTcTy2jeu63q0D3PlwDx2FQMgYDBgmk/J8LqWPQuFRhV6z2q0VF94iJ9pOBAAh+QQBCgAPACwAAAAAEAAQAAAESPDJ+YSgmFqb5xjV9gQB9n3hSJbeSa1sm5EUQXQTADy2jeu63q0D3PlwDx2lUMgcDhgmk/J8LqUPg+FRhV6z2q0VF94iJ9pOBAAh+QQBCgAPACwAAAAAEAAQAAAESPDJ+cagmFqbJyHV9ggC9n3hSJbeSa1sm5FUUXRTEDy2jeu63q0D3PlwDx3FYMgAABgmk/J8LqWPw+FRhV6z2q0VF94iJ9pOBAAh+QQBCgAPACwAAAAAEAAQAAAESPDJ+QihmFqbZynV9gwD9n3hSJbeSa1sm5GUYXSTIDy2jeu63q0D3PlwDx3lcMgEAhgmk/J8LqUPAOBRhV6z2q0VF94iJ9pOBAAh+QQBCgAPACwAAAAAEAAQAAAESPDJ+UqhmFqbpzHV9hAE9n3hSJbeSa1sm5HUcXTTMDy2jeu63q0D3PlwDx0FAMgIBBgmk/J8LqWPQOBRhV6z2q0VF94iJ9pOBAAh+QQBCgAPACwAAAAAEAAQAAAESPDJ+YyhmFqb5znV9hQF9n3hSJbeSa1sm5EUAHQTQTy2jeu63q0D3PlwDx0lEMgMBhgmk/J8LqUPgeBRhV6z2q0VF94iJ9pOBAAh+QQBCgAPACwAAAAAEAAQAAAESPDJ+c6hmFqbJwDV9hgG9n3hSJbeSa1sm5FUEHRTUTy2jeu63q0D3PlwDx1FIMgQCBgmk/J8LqWPweBRhV6z2q0VF94iJ9pOBAA7'; /******************************************************************************/ document.addEventListener('DOMContentLoaded', init); /******************************************************************************/ function init() { for (var site in sites) { var div = document.body.appendChild(document.createElement('div')); var querier = document.createElement('a'); querier.textContent = site; querier.target = '_blank'; querier.href = sites[site].openPageURL || sites[site].checkPageURL; div.appendChild(querier); } if(!location.hash){getAll();} } /******************************************************************************/ function getAll() { var queriers = document.querySelectorAll('a'); for (var i = 0, querier; querier = queriers[i]; i++) { window.setTimeout(getDoc, i*1000, querier); } } /******************************************************************************/ function getDoc(querier) { querier.style.backgroundImage = 'url('+ throbber + ')'; var site = querier.textContent; var xhr = new XMLHttpRequest(); xhr.open('GET', sites[site].checkPageURL, true); xhr.setRequestHeader('Accept-Language','en-US,en;q=0.8,ru;q=0.6,uk;q=0.4,qya;q=0.001'); xhr.responseType = 'document'; xhr.timeout = 10000; xhr.withCredentials = true; xhr.onload = function() { processDoc(this.response, querier); }; xhr.ontimeout = xhr.onerror = function(evt) { querier.parentNode.appendChild(document.createElement('pre')).textContent = evt.type.charAt(0).toUpperCase() + evt.type.slice(1) + '.'; querier.style.backgroundImage = 'none'; }; xhr.send(null); } /******************************************************************************/ function processDoc(doc, querier) { var site = querier.textContent; var keyElements = doc.querySelectorAll(sites[site].keyElementSelectors); if (keyElements.length) { querier.parentNode.appendChild(document.createElement('pre')).textContent = [].map.call(keyElements, function(el) { el = el.textContent.trim().replace(/\s+/g, ' '); if (sites[site].re) {el = el.replace(sites[site].re[0], sites[site].re[1]);} return el; }).join('\n'); } else { querier.parentNode.appendChild(document.createElement('pre')).textContent = 'Parsing error.'; } querier.style.backgroundImage = 'none'; } /******************************************************************************/ </script> </head> <body></body> </html>
localStorage
, , , indexedDB
.localStorage
, IE11 — (, , , Edge). Fiddler . . , , IE11 localStorage
. Fiddler-, «AutoResponder» ( , Fiddler , URL):localhost
( 127.0.0.1
; , , ), IE11; . IE11. , , , , status quo: <!doctype html> <html> <head> <meta charset='UTF-8'><title>IMDb Charts History</title> <style> body > div > * {padding: 5px 20px 5px 20px; margin: 2px;} body > div > a {display: inline-block; background-repeat: no-repeat; background-position: left center;} body > div > pre {border: 1px solid silver;} body > div > pre:not(:first-of-type) {background-color: gainsboro;} body > div > pre > button {margin: 0px 0px 0px 20px;} </style> <script> /******************************************************************************/ 'use strict'; /******************************************************************************/ var sites = { 'IMDb Top 250': { checkPageURL: 'http://www.imdb.com/chart/top', keyElementsSelector: '#main > div > span > div > div > div.lister > table > tbody > tr > td.titleColumn > a', }, 'IMDb Top 250 TV': { checkPageURL: 'http://www.imdb.com/chart/toptv', keyElementsSelector: '#main > div > span > div > div > div.lister > table > tbody > tr > td.titleColumn > a', }, }; /******************************************************************************/ var netData = JSON.parse(localStorage['IMDbChartsHistory.netData'] || '{}'); var throbber = 'data:image/gif;base64,R0lGODlhEAAQAOMIAAAAABoaGjMzM0xMTGZmZoCAgJmZmbKysv///////////////////////////////yH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgAIACwAAAAAEAAQAAAESBDJiQCgmFqbZwjVhhwH9n3hSJbeSa1sm5GUIHSTYSC2jeu63q0D3PlwCB1lMMgUChgmk/J8LqUIAgFRhV6z2q0VF94iJ9pOBAAh+QQBCgAPACwAAAAAEAAQAAAESPDJ+UKgmFqbpxDV9gAA9n3hSJbeSa1sm5HUMHTTcTy2jeu63q0D3PlwDx2FQMgYDBgmk/J8LqWPQuFRhV6z2q0VF94iJ9pOBAAh+QQBCgAPACwAAAAAEAAQAAAESPDJ+YSgmFqb5xjV9gQB9n3hSJbeSa1sm5EUQXQTADy2jeu63q0D3PlwDx2lUMgcDhgmk/J8LqUPg+FRhV6z2q0VF94iJ9pOBAAh+QQBCgAPACwAAAAAEAAQAAAESPDJ+cagmFqbJyHV9ggC9n3hSJbeSa1sm5FUUXRTEDy2jeu63q0D3PlwDx3FYMgAABgmk/J8LqWPw+FRhV6z2q0VF94iJ9pOBAAh+QQBCgAPACwAAAAAEAAQAAAESPDJ+QihmFqbZynV9gwD9n3hSJbeSa1sm5GUYXSTIDy2jeu63q0D3PlwDx3lcMgEAhgmk/J8LqUPAOBRhV6z2q0VF94iJ9pOBAAh+QQBCgAPACwAAAAAEAAQAAAESPDJ+UqhmFqbpzHV9hAE9n3hSJbeSa1sm5HUcXTTMDy2jeu63q0D3PlwDx0FAMgIBBgmk/J8LqWPQOBRhV6z2q0VF94iJ9pOBAAh+QQBCgAPACwAAAAAEAAQAAAESPDJ+YyhmFqb5znV9hQF9n3hSJbeSa1sm5EUAHQTQTy2jeu63q0D3PlwDx0lEMgMBhgmk/J8LqUPgeBRhV6z2q0VF94iJ9pOBAAh+QQBCgAPACwAAAAAEAAQAAAESPDJ+c6hmFqbJwDV9hgG9n3hSJbeSa1sm5FUEHRTUTy2jeu63q0D3PlwDx1FIMgQCBgmk/J8LqWPweBRhV6z2q0VF94iJ9pOBAA7'; /******************************************************************************/ document.addEventListener('DOMContentLoaded', init); /******************************************************************************/ function init() { for (var site in sites) { if(!netData[site]) { netData[site] = {lastEntries: [], lastEntriesTitles: [], history: [], saveHistory: true, lastCheck: ''}; } var div = document.body.appendChild(document.createElement('div')); var watcher = div.appendChild(document.createElement('a')); watcher.textContent = site; watcher.target = '_blank'; watcher.href = sites[site].openPageURL || sites[site].checkPageURL; } localStorage['IMDbChartsHistory.netData'] = JSON.stringify(netData); if(!location.hash){getAll();} } /******************************************************************************/ function getAll() { var watchers = document.querySelectorAll('a'); for (var i = 0, watcher; watcher = watchers[i]; i++) { window.setTimeout(getDoc, i*2000, watcher); } } /******************************************************************************/ function getDoc(watcher) { watcher.style.backgroundImage = 'url('+ throbber + ')'; var site = watcher.textContent; var xhr = new XMLHttpRequest(); xhr.open('GET', sites[site].checkPageURL, true); xhr.setRequestHeader('Accept-Language','en-US,en;q=0.8,ru;q=0.6,uk;q=0.4,qya;q=0.001'); xhr.responseType = 'document'; xhr.timeout = 10000; xhr.withCredentials = true; xhr.onload = function() { processDoc(this.response, watcher); }; xhr.ontimeout = xhr.onerror = function(evt) { watcher.parentNode.appendChild(document.createElement('pre')).textContent = evt.type.charAt(0).toUpperCase() + evt.type.slice(1) + '.'; watcher.style.backgroundImage = 'none'; }; xhr.send(null); } /******************************************************************************/ function processDoc(doc, watcher) { var site = watcher.textContent; var siteData = netData[site]; var keyElements = doc.querySelectorAll(sites[site].keyElementsSelector); var info, news; if (keyElements.length) { var now = new Date(Date.now()).toLocaleString(); var curEntries = [].map.call(keyElements, function(el) { el.search = ''; return el.href; }); var curEntriesTitles = [].map.call(keyElements, function(el) { return el.textContent; }); if (siteData.lastEntries.length) { var added = curEntries.filter(function(el) { return siteData.lastEntries.indexOf(el) == -1; }).map(function(el) { var ci = curEntries.indexOf(el); return '+ ' + (ci + 1) + '\t<a href="' + el + '">' + curEntriesTitles[ci] + '</a>'; }); var removed = siteData.lastEntries.filter(function(el) { return curEntries.indexOf(el) == -1; }).map(function(el) { var li = siteData.lastEntries.indexOf(el); return '- (' + (li + 1) + ')\t<a href="' + el + '">' + siteData.lastEntriesTitles[li] + '</a>'; }); var risen = siteData.lastEntries.filter(function(el, li) { var ci = curEntries.indexOf(el); return ci > -1 && ci < li; }).map(function(el) { var ci = curEntries.indexOf(el); return '↑ ' + (siteData.lastEntries.indexOf(el) + 1) + '\t→\t' + (ci + 1) + '\t<a href="' + el + '">' + curEntriesTitles[ci] + '</a>'; }); var fallen = siteData.lastEntries.filter(function(el, li) { return curEntries.indexOf(el) > li; }).map(function(el) { var ci = curEntries.indexOf(el); return '↓ ' + (siteData.lastEntries.indexOf(el) + 1) + '\t→\t' + (ci + 1) + '\t<a href="' + el + '">' + curEntriesTitles[ci] + '</a>'; }); news = added.length || removed.length || risen.length || fallen.length; info = now + ' (previous check: ' + siteData.lastCheck + ')<hr>' + (news? [added.join('\n'), removed.join('\n'), risen.join('\n'), fallen.join('\n')] .filter(function(el){return el.length;}).join('\n\n') : 'No news.' ); } else { info = now + '<hr>First launch. Data saved (' + curEntries.length + ' entries).'; } watcher.parentNode.appendChild(document.createElement('pre')).innerHTML = info; var historyHeader = watcher.parentNode.appendChild(document.createElement('pre')); var historyOptionLabel = historyHeader.appendChild(document.createElement('label')); var historyOption = historyOptionLabel.appendChild(document.createElement('input')); historyOption.type = 'checkbox'; historyOption.checked = siteData.saveHistory; historyOption.addEventListener('click', toggleHistory); historyOptionLabel.appendChild(document.createTextNode('Save history')); var clearer = historyHeader.appendChild(document.createElement('button')); clearer.type = 'button'; clearer.textContent = 'Clear history'; clearer.disabled = !siteData.history.length; clearer.addEventListener('click', clearHistory); watcher.parentNode.appendChild(document.createElement('pre')).innerHTML = siteData.history.length? siteData.history.join('\n<hr>\n') : 'No history.'; siteData.lastEntries = curEntries; siteData.lastEntriesTitles = curEntriesTitles; if (news && siteData.saveHistory) {siteData.history.unshift(info);} siteData.lastCheck = now; localStorage['IMDbChartsHistory.netData'] = JSON.stringify(netData); } else { watcher.parentNode.appendChild(document.createElement('pre')).textContent = 'Parsing error.'; } watcher.style.backgroundImage = 'none'; } /******************************************************************************/ function toggleHistory(evt) { var site = evt.target.parentNode.parentNode.parentNode.querySelector('a').textContent; var siteData = netData[site]; siteData.saveHistory = evt.target.checked; localStorage['IMDbChartsHistory.netData'] = JSON.stringify(netData); } /******************************************************************************/ function clearHistory(evt) { var site = evt.target.parentNode.parentNode.querySelector('a').textContent; var siteData = netData[site]; siteData.history = []; evt.target.parentNode.parentNode.querySelector('pre:last-of-type').innerHTML = 'History cleared.'; localStorage['IMDbChartsHistory.netData'] = JSON.stringify(netData); evt.target.disabled = true; } /******************************************************************************/ </script> </head> <body></body> </html>
<!doctype html> <html> <head><meta charset="UTF-8"><title>Bookmarklets</title></head> <body style="text-align: center; font-family: monospace; font-size: 12pt;"> <p><a href="javascript:(function(url, xhr) {if(!url) {return;}xhr = new XMLHttpRequest();try {xhr.open('HEAD', url, true);}catch (e) {alert(e.name + ': ' + e.message);return;}xhr.setRequestHeader('Accept-Language', 'en-US,en;q=0.8,ru;q=0.6,uk;q=0.4,qya;q=0.001');xhr.responseType = 'document';xhr.timeout = 10000;xhr.withCredentials = true;xhr.onload = function(evt, l) {l = this.getResponseHeader('Content-Length');alert([this.responseURL || '?',this.getResponseHeader('Content-Type') || '?',this.getResponseHeader('Last-Modified') || '?',l ?[l + ' B',(l / 1024) .toFixed(3) + ' kB',(l / 1048576) .toFixed(3) + ' MB',(l / 1073741824).toFixed(3) + ' GB'].join(' \u2248 '):'?'].join('\n\n') + '\n\n');};xhr.ontimeout = xhr.onerror = function(evt) {alert(evt.type.charAt(0).toUpperCase() + evt.type.slice(1) + '.');};try {xhr.send(null);}catch (e) {alert(e.name + ': ' + e.message); return;}})(document.activeElement.href || prompt('URL:'))"> </a></p> <p><a href="javascript:(function(e,t,n,a,A,i,r,o,l,p,d,s){function h(e,t){s.style.backgroundImage='url('+n+')',t=new XMLHttpRequest;try{t.open('GET',e.href,!0)}catch(a){return s.style.backgroundImage='none',void(s.textContent=a.name+': '+a.message)}t.setRequestHeader('Accept-Language','en-US,en;q=0.8,ru;q=0.6,uk;q=0.4,qya;q=0.001'),t.responseType='document',t.timeout=1e4,t.withCredentials=!0,t.onload=function(){s.style.backgroundImage='none',this.response&&this.response.title?(s.textContent=this.response.title,e.setAttribute('data-breadcrumbs-doc-title',this.response.title)):(s.textContent='?',e.setAttribute('data-breadcrumbs-doc-title','?'))},t.ontimeout=t.onerror=function(e){s.style.backgroundImage='none',s.textContent=e.type.charAt(0).toUpperCase()+e.type.slice(1)+'.'};try{t.send(null)}catch(a){s.style.backgroundImage='none',s.textContent=a.name+': '+a.message}}for(t=e.activeElement.href?e.activeElement:location,n='data:image/gif;base64,R0lGODlhEAAQAOMIAAAAABoaGjMzM0xMTGZmZoCAgJmZmbKysv///////////////////////////////yH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgAIACwAAAAAEAAQAAAESBDJiQCgmFqbZwjVhhwH9n3hSJbeSa1sm5GUIHSTYSC2jeu63q0D3PlwCB1lMMgUChgmk/J8LqUIAgFRhV6z2q0VF94iJ9pOBAAh+QQBCgAPACwAAAAAEAAQAAAESPDJ+UKgmFqbpxDV9gAA9n3hSJbeSa1sm5HUMHTTcTy2jeu63q0D3PlwDx2FQMgYDBgmk/J8LqWPQuFRhV6z2q0VF94iJ9pOBAAh+QQBCgAPACwAAAAAEAAQAAAESPDJ+YSgmFqb5xjV9gQB9n3hSJbeSa1sm5EUQXQTADy2jeu63q0D3PlwDx2lUMgcDhgmk/J8LqUPg+FRhV6z2q0VF94iJ9pOBAAh+QQBCgAPACwAAAAAEAAQAAAESPDJ+cagmFqbJyHV9ggC9n3hSJbeSa1sm5FUUXRTEDy2jeu63q0D3PlwDx3FYMgAABgmk/J8LqWPw+FRhV6z2q0VF94iJ9pOBAAh+QQBCgAPACwAAAAAEAAQAAAESPDJ+QihmFqbZynV9gwD9n3hSJbeSa1sm5GUYXSTIDy2jeu63q0D3PlwDx3lcMgEAhgmk/J8LqUPAOBRhV6z2q0VF94iJ9pOBAAh+QQBCgAPACwAAAAAEAAQAAAESPDJ+UqhmFqbpzHV9hAE9n3hSJbeSa1sm5HUcXTTMDy2jeu63q0D3PlwDx0FAMgIBBgmk/J8LqWPQOBRhV6z2q0VF94iJ9pOBAAh+QQBCgAPACwAAAAAEAAQAAAESPDJ+YyhmFqb5znV9hQF9n3hSJbeSa1sm5EUAHQTQTy2jeu63q0D3PlwDx0lEMgMBhgmk/J8LqUPgeBRhV6z2q0VF94iJ9pOBAAh+QQBCgAPACwAAAAAEAAQAAAESPDJ+c6hmFqbJwDV9hgG9n3hSJbeSa1sm5FUEHRTUTy2jeu63q0D3PlwDx1FIMgQCBgmk/J8LqWPweBRhV6z2q0VF94iJ9pOBAA7',a=e.createElement('div'),a.setAttribute('data-breadcrumbs-main',''),a.appendChild(e.createElement('style')).textContent='div[data-breadcrumbs-main] {position:fixed; top:0px; left:0; z-index:999999; width:100%; padding:10px !important; background-color:white !important; outline:1px solid black !important; font-size: 12pt !important; text-align: left !important;}\ndiv[data-breadcrumbs-main] a {font-size: 12pt !important; text-decoration: underline !important;}\ndiv[data-breadcrumbs-main] div {margin-top: 20px!important; color: silver !important;}\ndiv[data-breadcrumbs-info-title] {background-repeat: no-repeat !important; background-position: left center !important; padding-left: 20px !important;}',A=t.protocol+(/:[\/][\/]/.test(t.href)?'//':''),a.appendChild(e.createElement('span')).textContent=A,i=t.hostname.split('.'),r=i.length,r>1&&(i.splice(r-2,2,i.slice(r-2).join('.')),r--),o=0;r>o;o++)l=i[o],o>0&&(a.appendChild(e.createElement('span')).textContent='.'),p=a.appendChild(e.createElement('a')),p.textContent=l,p.href=A+i.slice(o).join('.');if(A+=t.hostname,t.port&&/:\d+$/.test(t.host)&&(a.appendChild(e.createElement('span')).textContent=':',p=a.appendChild(e.createElement('a')),p.textContent=t.port,A+=':'+t.port,p.href=A),a.appendChild(e.createElement('span')).textContent='/',A+='/',t.pathname.length>1)for(i=t.pathname.split('/'),i.shift(),r=i.length,o=0;r>o;o++)l=i[o],r-1>o?(p=a.appendChild(e.createElement('a')),p.textContent=l,A+=l,a.appendChild(e.createElement('span')).textContent='/',A+='/',p.href=A):''!==l&&(p=a.appendChild(e.createElement('a')),p.textContent=l,A+=l,p.href=A);if(t.search)for(i=t.search.split('&'),r=i.length,i[0]=i[0].substring(1),a.appendChild(e.createElement('span')).textContent='?',A+='?',o=0;r>o;o++)l=i[o],o>0&&(a.appendChild(e.createElement('span')).textContent='&',A+='&'),p=a.appendChild(e.createElement('a')),p.textContent=l,A+=l,p.href=A;t.hash&&(a.appendChild(e.createElement('span')).textContent='#',p=a.appendChild(e.createElement('a')),p.textContent=t.hash.substring(1),A+=t.hash,p.href=A),a.querySelector('a:last-of-type').href==location.href&&a.querySelector('a:last-of-type').setAttribute('data-breadcrumbs-doc-title',e.title),d=a.appendChild(e.createElement('div')),d.setAttribute('data-breadcrumbs-info-url',''),d.textContent='URL',s=a.appendChild(e.createElement('div')),s.setAttribute('data-breadcrumbs-info-title',''),s.textContent='Title',a.addEventListener('mouseover',function(e,t,n){(t=e.target.href)&&(d.textContent=t,(n=e.target.getAttribute('data-breadcrumbs-doc-title'))?s.textContent=n:h(e.target))}),a.addEventListener('dblclick',function(){a.parentNode.removeChild(a)}),e.body.appendChild(a)})(document)"> </a></p> </body> </html>
XMLHttpRequest.withCredentials
;null Access-Control-Allow-Origin
: Origin
null
, .navigator.languages
;XMLHttpRequest.responseURL
;localStorage
.Source: https://habr.com/ru/post/265013/
All Articles