Unrelated quirks:

- missing icons for magnifier (because https://github.com/uBlockOrigin/uMatrix-issues/issues/68)
- missing i18n string
- use separate file for CSS styles
pull/2/head
Raymond Hill 6 years ago
parent 495dddc389
commit 886664abd4
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

@ -655,6 +655,10 @@
"message": "Because of the following rule",
"description": "English: Because of the following rule"
},
"mainBlockedNoParamsPrompt": {
"message": "without parameters",
"description": "label to be used for the parameter-less URL: https://cloud.githubusercontent.com/assets/585534/9832014/bfb1b8f0-593b-11e5-8a27-fba472a5529a.png"
},
"mainBlockedBack" : {
"message": "Go back",
"description": "English: Go back"

@ -63,6 +63,8 @@
.fa-icon > .fa-icon_power-off,
.fa-icon > .fa-icon_question-circle,
.fa-icon > .fa-icon_reply,
.fa-icon > .fa-icon_search-minus,
.fa-icon > .fa-icon_search-plus,
.fa-icon > .fa-icon_spinner,
.fa-icon > .fa-icon_sync-alt,
.fa-icon > .fa-icon_th,

@ -27,6 +27,8 @@ License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL
<symbol id="question-circle" viewBox="0 0 512 512"><path d="M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zM262.655 90c-54.497 0-89.255 22.957-116.549 63.758-3.536 5.286-2.353 12.415 2.715 16.258l34.699 26.31c5.205 3.947 12.621 3.008 16.665-2.122 17.864-22.658 30.113-35.797 57.303-35.797 20.429 0 45.698 13.148 45.698 32.958 0 14.976-12.363 22.667-32.534 33.976C247.128 238.528 216 254.941 216 296v4c0 6.627 5.373 12 12 12h56c6.627 0 12-5.373 12-12v-1.333c0-28.462 83.186-29.647 83.186-106.667 0-58.002-60.165-102-116.531-102zM256 338c-25.365 0-46 20.635-46 46 0 25.364 20.635 46 46 46s46-20.636 46-46c0-25.365-20.635-46-46-46z"></path></symbol>
<symbol id="reply" viewBox="0 0 512 512"><path d="M8.309 189.836L184.313 37.851C199.719 24.546 224 35.347 224 56.015v80.053c160.629 1.839 288 34.032 288 186.258 0 61.441-39.581 122.309-83.333 154.132-13.653 9.931-33.111-2.533-28.077-18.631 45.344-145.012-21.507-183.51-176.59-185.742V360c0 20.7-24.3 31.453-39.687 18.164l-176.004-152c-11.071-9.562-11.086-26.753 0-36.328z"/></symbol>
<symbol id="reply-all" viewBox="0 0 576 512"><path d="M136.309 189.836L312.313 37.851C327.72 24.546 352 35.348 352 56.015v82.763c129.182 10.231 224 52.212 224 183.548 0 61.441-39.582 122.309-83.333 154.132-13.653 9.931-33.111-2.533-28.077-18.631 38.512-123.162-3.922-169.482-112.59-182.015v84.175c0 20.701-24.3 31.453-39.687 18.164L136.309 226.164c-11.071-9.561-11.086-26.753 0-36.328zm-128 36.328L184.313 378.15C199.7 391.439 224 380.687 224 359.986v-15.818l-108.606-93.785A55.96 55.96 0 0 1 96 207.998a55.953 55.953 0 0 1 19.393-42.38L224 71.832V56.015c0-20.667-24.28-31.469-39.687-18.164L8.309 189.836c-11.086 9.575-11.071 26.767 0 36.328z"/></symbol>
<symbol id="search-minus" viewBox="0 0 512 512"><path d="M304 192v32c0 6.6-5.4 12-12 12H124c-6.6 0-12-5.4-12-12v-32c0-6.6 5.4-12 12-12h168c6.6 0 12 5.4 12 12zm201 284.7L476.7 505c-9.4 9.4-24.6 9.4-33.9 0L343 405.3c-4.5-4.5-7-10.6-7-17V372c-35.3 27.6-79.7 44-128 44C93.1 416 0 322.9 0 208S93.1 0 208 0s208 93.1 208 208c0 48.3-16.4 92.7-44 128h16.3c6.4 0 12.5 2.5 17 7l99.7 99.7c9.3 9.4 9.3 24.6 0 34zM344 208c0-75.2-60.8-136-136-136S72 132.8 72 208s60.8 136 136 136 136-60.8 136-136z"></path></symbol>
<symbol id="search-plus" viewBox="0 0 512 512"><path d="M304 192v32c0 6.6-5.4 12-12 12h-56v56c0 6.6-5.4 12-12 12h-32c-6.6 0-12-5.4-12-12v-56h-56c-6.6 0-12-5.4-12-12v-32c0-6.6 5.4-12 12-12h56v-56c0-6.6 5.4-12 12-12h32c6.6 0 12 5.4 12 12v56h56c6.6 0 12 5.4 12 12zm201 284.7L476.7 505c-9.4 9.4-24.6 9.4-33.9 0L343 405.3c-4.5-4.5-7-10.6-7-17V372c-35.3 27.6-79.7 44-128 44C93.1 416 0 322.9 0 208S93.1 0 208 0s208 93.1 208 208c0 48.3-16.4 92.7-44 128h16.3c6.4 0 12.5 2.5 17 7l99.7 99.7c9.3 9.4 9.3 24.6 0 34zM344 208c0-75.2-60.8-136-136-136S72 132.8 72 208s60.8 136 136 136 136-60.8 136-136z"></path></symbol>
<symbol id="spinner" viewBox="0 0 512 512"><path d="M304 48c0 26.51-21.49 48-48 48s-48-21.49-48-48 21.49-48 48-48 48 21.49 48 48zm-48 368c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zm208-208c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zM96 256c0-26.51-21.49-48-48-48S0 229.49 0 256s21.49 48 48 48 48-21.49 48-48zm12.922 99.078c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.491-48-48-48zm294.156 0c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.49-48-48-48zM108.922 60.922c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.491-48-48-48z"></path></symbol>
<symbol id="sync-alt" viewBox="0 0 512 512"><path d="M370.72 133.28C339.458 104.008 298.888 87.962 255.848 88c-77.458.068-144.328 53.178-162.791 126.85-1.344 5.363-6.122 9.15-11.651 9.15H24.103c-7.498 0-13.194-6.807-11.807-14.176C33.933 94.924 134.813 8 256 8c66.448 0 126.791 26.136 171.315 68.685L463.03 40.97C478.149 25.851 504 36.559 504 57.941V192c0 13.255-10.745 24-24 24H345.941c-21.382 0-32.09-25.851-16.971-40.971l41.75-41.749zM32 296h134.059c21.382 0 32.09 25.851 16.971 40.971l-41.75 41.75c31.262 29.273 71.835 45.319 114.876 45.28 77.418-.07 144.315-53.144 162.787-126.849 1.344-5.363 6.122-9.15 11.651-9.15h57.304c7.498 0 13.194 6.807 11.807 14.176C478.067 417.076 377.187 504 256 504c-66.448 0-126.791-26.136-171.315-68.685L48.97 471.03C33.851 486.149 8 475.441 8 454.059V320c0-13.255 10.745-24 24-24z"/></symbol>
<symbol id="th" viewBox="0 0 512 512"><path d="M149.333 56v80c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V56c0-13.255 10.745-24 24-24h101.333c13.255 0 24 10.745 24 24zm181.334 240v-80c0-13.255-10.745-24-24-24H205.333c-13.255 0-24 10.745-24 24v80c0 13.255 10.745 24 24 24h101.333c13.256 0 24.001-10.745 24.001-24zm32-240v80c0 13.255 10.745 24 24 24H488c13.255 0 24-10.745 24-24V56c0-13.255-10.745-24-24-24H386.667c-13.255 0-24 10.745-24 24zm-32 80V56c0-13.255-10.745-24-24-24H205.333c-13.255 0-24 10.745-24 24v80c0 13.255 10.745 24 24 24h101.333c13.256 0 24.001-10.745 24.001-24zm-205.334 56H24c-13.255 0-24 10.745-24 24v80c0 13.255 10.745 24 24 24h101.333c13.255 0 24-10.745 24-24v-80c0-13.255-10.745-24-24-24zM0 376v80c0 13.255 10.745 24 24 24h101.333c13.255 0 24-10.745 24-24v-80c0-13.255-10.745-24-24-24H24c-13.255 0-24 10.745-24 24zm386.667-56H488c13.255 0 24-10.745 24-24v-80c0-13.255-10.745-24-24-24H386.667c-13.255 0-24 10.745-24 24v80c0 13.255 10.745 24 24 24zm0 160H488c13.255 0 24-10.745 24-24v-80c0-13.255-10.745-24-24-24H386.667c-13.255 0-24 10.745-24 24v80c0 13.255 10.745 24 24 24zM181.333 376v80c0 13.255 10.745 24 24 24h101.333c13.255 0 24-10.745 24-24v-80c0-13.255-10.745-24-24-24H205.333c-13.255 0-24 10.745-24 24z"/></symbol>

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 19 KiB

@ -1,7 +1,7 @@
/*******************************************************************************
uMatrix - a browser extension to block requests.
Copyright (C) 2015-2017 Raymond Hill
Copyright (C) 2015-present Raymond Hill
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -29,10 +29,10 @@
/******************************************************************************/
var details = {};
let details = {};
(function() {
var matches = /details=([^&]+)/.exec(window.location.search);
let matches = /details=([^&]+)/.exec(window.location.search);
if ( matches === null ) { return; }
try {
details = JSON.parse(atob(matches[1]));
@ -52,17 +52,15 @@ uDom('.what').text(details.url);
// https://github.com/gorhill/uBlock/blob/master/src/js/document-blocked.js
(function() {
if ( typeof URL !== 'function' ) { return; }
let reURL = /^https?:\/\//;
var reURL = /^https?:\/\//;
var liFromParam = function(name, value) {
let liFromParam = function(name, value) {
if ( value === '' ) {
value = name;
name = '';
}
var li = document.createElement('li');
var span = document.createElement('span');
let li = document.createElement('li');
let span = document.createElement('span');
span.textContent = name;
li.appendChild(span);
if ( name !== '' && value !== '' ) {
@ -70,7 +68,7 @@ uDom('.what').text(details.url);
}
span = document.createElement('span');
if ( reURL.test(value) ) {
var a = document.createElement('a');
let a = document.createElement('a');
a.href = a.textContent = value;
span.appendChild(a);
} else {
@ -80,7 +78,7 @@ uDom('.what').text(details.url);
return li;
};
var safeDecodeURIComponent = function(s) {
let safeDecodeURIComponent = function(s) {
try {
s = decodeURIComponent(s);
} catch (ex) {
@ -88,31 +86,30 @@ uDom('.what').text(details.url);
return s;
};
var renderParams = function(parentNode, rawURL) {
var a = document.createElement('a');
let renderParams = function(parentNode, rawURL) {
let a = document.createElement('a');
a.href = rawURL;
if ( a.search.length === 0 ) { return false; }
var pos = rawURL.indexOf('?');
var li = liFromParam(
vAPI.i18n('docblockedNoParamsPrompt'),
let pos = rawURL.indexOf('?');
let li = liFromParam(
vAPI.i18n('mainBlockedNoParamsPrompt'),
rawURL.slice(0, pos)
);
parentNode.appendChild(li);
var params = a.search.slice(1).split('&');
var param, name, value, ul;
let params = a.search.slice(1).split('&');
for ( var i = 0; i < params.length; i++ ) {
param = params[i];
pos = param.indexOf('=');
let param = params[i];
let pos = param.indexOf('=');
if ( pos === -1 ) {
pos = param.length;
}
name = safeDecodeURIComponent(param.slice(0, pos));
value = safeDecodeURIComponent(param.slice(pos + 1));
let name = safeDecodeURIComponent(param.slice(0, pos));
let value = safeDecodeURIComponent(param.slice(pos + 1));
li = liFromParam(name, value);
if ( reURL.test(value) ) {
ul = document.createElement('ul');
let ul = document.createElement('ul');
renderParams(ul, value);
li.appendChild(ul);
}
@ -121,25 +118,30 @@ uDom('.what').text(details.url);
return true;
};
if ( renderParams(uDom.nodeFromId('parsed'), details.url) === false ) {
return;
}
let hasParams = renderParams(uDom.nodeFromId('parsed'), details.url);
if ( hasParams === false ) { return; }
var toggler = document.createElement('span');
toggler.className = 'fa';
uDom('#theURL > p').append(toggler);
let theURLNode = document.getElementById('theURL');
theURLNode.classList.add('hasParams');
theURLNode.classList.toggle(
'collapsed',
vAPI.localStorage.getItem('document-blocked-collapse-url') === 'true'
);
uDom(toggler).on('click', function() {
var collapsed = uDom.nodeFromId('theURL').classList.toggle('collapsed');
let toggleCollapse = function() {
vAPI.localStorage.setItem(
'document-blocked-collapse-url',
collapsed.toString()
theURLNode.classList.toggle('collapsed').toString()
);
});
};
uDom.nodeFromId('theURL').classList.toggle(
'collapsed',
vAPI.localStorage.getItem('document-blocked-collapse-url') === 'true'
theURLNode.querySelector('.collapse').addEventListener(
'click',
toggleCollapse
);
theURLNode.querySelector('.expand').addEventListener(
'click',
toggleCollapse
);
})();
@ -161,8 +163,8 @@ vAPI.messaging.send('main-blocked.js', {
what: 'mustBlock',
scope: details.hn,
hostname: details.hn,
type: 'doc'
}, function(response) {
type: details.type
}, response => {
if ( response === false ) {
window.location.replace(details.url);
}

@ -35,6 +35,7 @@ var onBeforeRootFrameRequestHandler = function(details) {
let µm = µMatrix;
let desURL = details.url;
let desHn = µm.URI.hostnameFromURI(desURL);
let type = requestTypeNormalizer[details.type] || 'other';
let tabId = details.tabId;
µm.tabContextManager.push(tabId, desURL);
@ -43,13 +44,13 @@ var onBeforeRootFrameRequestHandler = function(details) {
let srcHn = tabContext.rootHostname;
// Disallow request as per matrix?
let blocked = µm.mustBlock(srcHn, desHn, 'doc');
let blocked = µm.mustBlock(srcHn, desHn, type);
let pageStore = µm.pageStoreFromTabId(tabId);
pageStore.recordRequest('doc', desURL, blocked);
pageStore.recordRequest(type, desURL, blocked);
pageStore.perLoadAllowedRequestCount = 0;
pageStore.perLoadBlockedRequestCount = 0;
µm.logger.writeOne({ tabId, srcHn, desHn, desURL, type: 'doc', blocked });
µm.logger.writeOne({ tabId, srcHn, desHn, desURL, type, blocked });
// Not blocked
if ( !blocked ) {
@ -62,7 +63,7 @@ var onBeforeRootFrameRequestHandler = function(details) {
}
// Blocked
let query = btoa(JSON.stringify({ url: desURL, hn: desHn, why: '?' }));
let query = btoa(JSON.stringify({ url: desURL, hn: desHn, type, why: '?' }));
vAPI.tabs.replace(tabId, vAPI.getURL('main-blocked.html?details=') + query);
@ -343,12 +344,18 @@ var onHeadersReceived = function(details) {
let µm = µMatrix,
tabId = details.tabId,
requestURL = details.url,
requestType = requestTypeNormalizer[details.type] || 'other';
requestType = requestTypeNormalizer[details.type] || 'other',
headers = details.responseHeaders;
// https://github.com/gorhill/uMatrix/issues/145
// Check if the main_frame is a download
if ( requestType === 'doc' ) {
µm.tabContextManager.push(tabId, requestURL);
let contentType = typeFromHeaders(headers);
if ( contentType !== undefined ) {
details.type = contentType;
return onBeforeRootFrameRequestHandler(details);
}
}
let tabContext = µm.tabContextManager.lookup(tabId);
@ -382,7 +389,6 @@ var onHeadersReceived = function(details) {
// if the current environment does not support merging headers:
// Firefox 58/webext and less can't merge CSP headers, so we will merge
// them here.
var headers = details.responseHeaders;
if ( csp.length !== 0 ) {
let cspRight = csp.join(', ');
@ -465,6 +471,20 @@ var headerIndexFromName = function(headerName, headers) {
/******************************************************************************/
// Extract request type from content headers.
let typeFromHeaders = function(headers) {
let i = headerIndexFromName('content-type', headers);
if ( i === -1 ) { return; }
let mime = headers[i].value.toLowerCase();
if ( mime.startsWith('image/') ) { return 'image'; }
if ( mime.startsWith('video/') || mime.startsWith('audio/') ) {
return 'media';
}
};
/******************************************************************************/
var requestTypeNormalizer = {
'font' : 'css',
'image' : 'image',

@ -1,119 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<link rel="stylesheet" href="css/common.css" type="text/css">
<style>
body {
font-family: sans-serif;
font-size: large;
text-align: center;
}
body > div {
margin: 1.5em 0;
}
body > div > p {
margin: 4px 0;
}
body > div > p:first-child {
margin: 1.5em 0 0 0;
}
.code {
background-color: rgba(0, 0, 0, 0.1);
display: inline-block;
font-family: monospace;
font-size: large;
line-height: 1.2;
padding: 2px 4px;
word-break: break-all;
}
button {
cursor: pointer;
margin: 0 1em 0.25em 1em;
padding: 0.25em 0.5em;
font-size: inherit;
}
#theURL {
margin: 0.25em 0;
padding: 0;
}
#theURL > * {
margin: 0;
}
#theURL > p {
position: relative;
z-index: 10;
}
#theURL > p > span {
background-color: transparent;
top: 100%;
box-sizing: border-box;
cursor: pointer;
opacity: 0.5;
padding: 0.2em;
position: absolute;
transform: translate(0, -50%);
}
body[dir="ltr"] #theURL > p > span {
right: 0;
}
body[dir="rtl"] #theURL > p > span {
left: 0;
}
#theURL > p:hover > span {
opacity: 1;
}
#theURL > p > span:before {
content: '\f010';
}
#theURL.collapsed > p > span:before {
content: '\f00e';
}
#parsed {
background-color: #f8f8f8;
border: 1px solid rgba(0, 0, 0, 0.1);
border-top: none;
color: gray;
font-size: small;
overflow-x: hidden;
padding: 4px;
text-align: initial;
text-overflow: ellipsis;
}
#theURL.collapsed > #parsed {
display: none;
}
#parsed ul, #parsed li {
list-style-type: none;
}
#parsed li {
white-space: nowrap;
}
#parsed span {
display: inline-block;
}
#parsed span:first-of-type {
font-weight: bold;
}
#warningSign {
margin: 1e, 0;
opacity: 1;
pointer-events: none;
width: 100%;
}
#warningSign > span {
color: #f2a500;
font-size: 180px;
}
</style>
<link rel="stylesheet" href="css/fa-icons.css">
<link rel="stylesheet" href="css/common.css">
<link rel="stylesheet" href="css/main-blocked.css">
</head>
<body>
<div id="warningSign"><span class="fa">&#xf071;</span></div>
<div id="warningSign"><span class="fa-icon">exclamation-triangle</span></div>
<div>
<p data-i18n="mainBlockedPrompt1"></p>
<div id="theURL" class="collapsed">
<p class="what code"></p>
<p>
<span class="what code"></span>
<span class="fa-icon expand">search-plus</span>
<span class="fa-icon collapse">search-minus</span>
</p>
<ul id="parsed"></ul>
</div>
</div>
@ -129,6 +33,7 @@ body[dir="rtl"] #theURL > p > span {
<button id="bye" data-i18n="mainBlockedClose" type="button"></button></p>
</div>
<script src="js/fa-icons.js"></script>
<script src="js/vapi-common.js"></script>
<script src="js/vapi-client.js"></script>
<script src="js/udom.js"></script>

Loading…
Cancel
Save