Skip to content

Commit 5d4f963

Browse files
committed
this fixes gorhill#298
1 parent 2619d31 commit 5d4f963

3 files changed

Lines changed: 58 additions & 4 deletions

File tree

src/document-blocked.html

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
body > div > p:first-child {
1919
margin: 1.5em 0 0 0;
2020
}
21+
a {
22+
text-decoration: none;
23+
}
2124
.code {
2225
background-color: rgba(0, 0, 0, 0.1);
2326
display: inline-block;
@@ -43,6 +46,16 @@
4346
color: #f2a500;
4447
font-size: 180px;
4548
}
49+
#whyex {
50+
font-size: smaller;
51+
opacity: 0.6;
52+
}
53+
#whyex:hover {
54+
opacity: 1;
55+
}
56+
#whyex a {
57+
white-space: nowrap;
58+
}
4659
.proceedChoice {
4760
display: inline-block;
4861
text-align: left;
@@ -61,7 +74,8 @@
6174

6275
<div>
6376
<p data-i18n="docblockedPrompt2"></p>
64-
<p id="why" class="code"></p>
77+
<p id="why" class="code"></p><!--
78+
--><span id="whyex" style="display: none;"><br>&#x2022; <span></span> &#x2022;</span>
6579
</div>
6680

6781
<div>

src/js/document-blocked.js

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,43 @@ var details = {};
4242

4343
/******************************************************************************/
4444

45+
(function() {
46+
var onReponseReady = function(response) {
47+
var lists = response.matches;
48+
if ( Array.isArray(lists) === false || lists.length === 0 ) {
49+
return;
50+
}
51+
var parent = uDom.nodeFromSelector('#whyex > span');
52+
var separator = '';
53+
var entry, url, node;
54+
for ( var i = 0; i < lists.length; i++ ) {
55+
entry = lists[i];
56+
if ( separator !== '' ) {
57+
parent.appendChild(document.createTextNode(separator));
58+
}
59+
url = entry.supportURL;
60+
if ( typeof url === 'string' && url !== '' ) {
61+
node = document.createElement('a');
62+
node.textContent = entry.title;
63+
node.setAttribute('href', url);
64+
node.setAttribute('target', '_blank');
65+
} else {
66+
node = document.createTextNode(entry.title);
67+
}
68+
parent.appendChild(node);
69+
separator = ' \u2022 ';
70+
}
71+
uDom.nodeFromId('whyex').style.removeProperty('display');
72+
};
73+
74+
messager.send({
75+
what: 'reverseLookupFilter',
76+
filter: details.fc
77+
}, onReponseReady);
78+
})();
79+
80+
/******************************************************************************/
81+
4582
var getTargetHostname = function() {
4683
var hostname = details.hn;
4784
var elem = document.querySelector('#proceed select');
@@ -103,8 +140,8 @@ var proceedPermanent = function() {
103140

104141
/******************************************************************************/
105142

106-
uDom('.what').text(details.url);
107-
uDom('#why').text(details.why);
143+
uDom.nodeFromSelector('.what').textContent = details.url;
144+
uDom.nodeFromId('why').textContent = details.fs;
108145

109146
if ( window.history.length > 1 ) {
110147
uDom('#back').on('click', function() { window.history.back(); });

src/js/traffic.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,15 @@ var onBeforeRootFrameRequest = function(details) {
219219
return;
220220
}
221221

222+
var compiled = result.slice(3);
223+
222224
// Blocked
223225
var query = btoa(JSON.stringify({
224226
url: requestURL,
225227
hn: requestHostname,
226228
dn: requestDomain,
227-
why: µb.staticNetFilteringEngine.filterStringFromCompiled(result.slice(3))
229+
fc: compiled,
230+
fs: µb.staticNetFilteringEngine.filterStringFromCompiled(compiled)
228231
}));
229232

230233
vAPI.tabs.replace(tabId, vAPI.getURL('document-blocked.html?details=') + query);

0 commit comments

Comments
 (0)