mirror of https://github.com/gorhill/uBlock.git
Output scriptlet logging information to the logger
This commit brings the following changes to the logger: All logging output generated by injected scriptlets are now sent to the logger, the developer console will no longer be used to log scriptlet logging information. When the logger is not opened, the scriplets will not output any logging information. The goal with this new approach is to allow filter authors to more easily assess the working of scriptlets without having to go through scriptlet parameters to enable logging. Consequently all the previous ways to tell scriptlets to log information are now obsolete: if the logger is opened, the scriptlets will log information to the logger. Another benefit of this approach is that the dev tools do not need to be open to obtain scriptlets logging information. Accordingly, new filter expressions have been added to the logger: "info" and "error". Selecting the "scriptlet" expression will also keep the logging information from scriptlets. A new button has been added to the logger (not yet i18n-ed): a "volume" icon, which allows to enable verbose mode. When verbose mode is enabled, the scriptlets may choose to output more information regarding their inner working. The entries in the logger will automatically expand on mouse hover. This allows to scroll through entries which text does not fit into a single row. Clicking anywhere on an entry in the logger will open the detailed view when applicable. Generic information/errors will now be rendered regardless of which tab is currently selected in the logger (similar to how tabless entries are already being rendered).
This commit is contained in:
parent
f1889b02ee
commit
869a653fdf
File diff suppressed because it is too large
Load Diff
|
@ -87,6 +87,19 @@ vAPI.app = {
|
|||
},
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
// Generate segments of random six alphanumeric characters, thus one segment
|
||||
// is a value out of 36^6 = over 2x10^9 values.
|
||||
|
||||
vAPI.generateSecret = (size = 1) => {
|
||||
let secret = '';
|
||||
while ( size-- ) {
|
||||
secret += (Math.floor(Math.random() * 2176782336) + 2176782336).toString(36).slice(1);
|
||||
}
|
||||
return secret;
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* https://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/API/storage/session
|
||||
|
@ -1165,11 +1178,6 @@ vAPI.messaging = {
|
|||
// Support using a new secret for every network request.
|
||||
|
||||
{
|
||||
// Generate a 6-character alphanumeric string, thus one random value out
|
||||
// of 36^6 = over 2x10^9 values.
|
||||
const generateSecret = ( ) =>
|
||||
(Math.floor(Math.random() * 2176782336) + 2176782336).toString(36).slice(1);
|
||||
|
||||
const root = vAPI.getURL('/');
|
||||
const reSecret = /\?secret=(\w+)/;
|
||||
const shortSecrets = [];
|
||||
|
@ -1207,7 +1215,7 @@ vAPI.messaging = {
|
|||
}
|
||||
}
|
||||
lastShortSecretTime = Date.now();
|
||||
const secret = generateSecret();
|
||||
const secret = vAPI.generateSecret();
|
||||
shortSecrets.push(secret);
|
||||
return secret;
|
||||
},
|
||||
|
@ -1215,7 +1223,7 @@ vAPI.messaging = {
|
|||
if ( previous !== undefined ) {
|
||||
longSecrets.delete(previous);
|
||||
}
|
||||
const secret = `${generateSecret()}${generateSecret()}${generateSecret()}`;
|
||||
const secret = vAPI.generateSecret(3);
|
||||
longSecrets.add(secret);
|
||||
return secret;
|
||||
},
|
||||
|
|
|
@ -95,6 +95,7 @@
|
|||
.fa-icon > .fa-icon_spinner,
|
||||
.fa-icon > .fa-icon_unlink,
|
||||
.fa-icon > .fa-icon_upload-alt,
|
||||
.fa-icon > .fa-icon_volume-up,
|
||||
.fa-icon > .fa-icon_zoom-in,
|
||||
.fa-icon > .fa-icon_zoom-out {
|
||||
width: calc(1em * 1664 / 1792);
|
||||
|
|
|
@ -218,6 +218,7 @@ body[dir="rtl"] #netInspector #filterExprPicker {
|
|||
width: 100%;
|
||||
}
|
||||
#vwRenderer .logEntry {
|
||||
background-color: var(--surface-1);
|
||||
display: block;
|
||||
left: 0;
|
||||
overflow: hidden;
|
||||
|
@ -228,7 +229,11 @@ body[dir="rtl"] #netInspector #filterExprPicker {
|
|||
display: none;
|
||||
}
|
||||
#vwRenderer .logEntry > div {
|
||||
border-bottom: 1px dotted var(--border-1);
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
height: 100%;
|
||||
max-height: 200px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
#vwRenderer .logEntry > div[data-status="1"],
|
||||
|
@ -271,7 +276,7 @@ body[dir="rtl"] #netInspector #filterExprPicker {
|
|||
color: white;
|
||||
}
|
||||
#vwRenderer .logEntry > div[data-type="error"] {
|
||||
color: var(--sf-error-ink);
|
||||
color: var(--cm-negative);
|
||||
}
|
||||
#vwRenderer .logEntry > div[data-type="info"] {
|
||||
color: var(--sf-def-ink);
|
||||
|
@ -283,10 +288,8 @@ body[dir="rtl"] #netInspector #filterExprPicker {
|
|||
opacity: 0.7;
|
||||
}
|
||||
|
||||
#vwRenderer .logEntry > div > span {
|
||||
border: 1px dotted var(--border-1);
|
||||
border-top: 0;
|
||||
border-right: 0;
|
||||
#vwRenderer .logEntry > .fields > span {
|
||||
border-left: 1px dotted var(--border-1);
|
||||
box-sizing: border-box;
|
||||
display: inline-block;
|
||||
height: 100%;
|
||||
|
@ -296,86 +299,74 @@ body[dir="rtl"] #netInspector #filterExprPicker {
|
|||
white-space: nowrap;
|
||||
word-break: break-all;
|
||||
}
|
||||
#vwRenderer .logEntry > div.canDetails:hover > span {
|
||||
#vwRenderer .logEntry > div:hover > span {
|
||||
background-color: rgba(0,0,0,0.04);
|
||||
}
|
||||
body[dir="ltr"] #vwRenderer .logEntry > div > span:first-child {
|
||||
body[dir="ltr"] #vwRenderer .logEntry > .fields > span:first-child {
|
||||
border-left: 0;
|
||||
}
|
||||
body[dir="rtl"] #vwRenderer .logEntry > div > span:first-child {
|
||||
body[dir="rtl"] #vwRenderer .logEntry > .fields > span:first-child {
|
||||
border-right: 0;
|
||||
}
|
||||
#vwRenderer .logEntry > div > span:nth-of-type(1) {
|
||||
}
|
||||
#vwRenderer .logEntry > div > span:nth-of-type(2) {
|
||||
}
|
||||
#vwRenderer .logEntry > div > span:nth-of-type(2) {
|
||||
#vwRenderer .logEntry > .fields > span:nth-of-type(2) {
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
#vwRenderer .logEntry > div.messageRealm > span:nth-of-type(2) ~ span {
|
||||
#vwRenderer .logEntry > .fields.messageRealm > span:nth-of-type(2) ~ span {
|
||||
display: none;
|
||||
}
|
||||
.vExpanded #vwRenderer #vwContent .logEntry > div > span:nth-of-type(2) {
|
||||
.vExpanded #vwRenderer #vwContent .logEntry > .fields > span:nth-of-type(2) {
|
||||
overflow-y: auto;
|
||||
white-space: pre-line;
|
||||
}
|
||||
#vwRenderer .logEntry > div.messageRealm[data-type="tabLoad"] > span:nth-of-type(2) {
|
||||
#vwRenderer .logEntry > .fields.messageRealm[data-type="tabLoad"] > span:nth-of-type(2) {
|
||||
text-align: center;
|
||||
}
|
||||
#vwRenderer .logEntry > div.extendedRealm > span:nth-of-type(2) > span:first-of-type {
|
||||
#vwRenderer .logEntry > .fields.extendedRealm > span:nth-of-type(2) > span:first-of-type {
|
||||
display: none;
|
||||
}
|
||||
#vwRenderer .logEntry > div.extendedRealm > span:nth-of-type(2) > span:last-of-type {
|
||||
pointer-events: none;
|
||||
}
|
||||
#vwRenderer .logEntry > div.extendedRealm.isException > span:nth-of-type(2) > span:last-of-type {
|
||||
#vwRenderer .logEntry > .fields.extendedRealm.isException > span:nth-of-type(2) > span:last-of-type {
|
||||
text-decoration: line-through rgba(0,0,255,0.7);
|
||||
}
|
||||
#vwRenderer .logEntry > div > span:nth-of-type(3) {
|
||||
#vwRenderer .logEntry > .fields > span:nth-of-type(3) {
|
||||
font-family: monospace;
|
||||
padding-left: 0.3em;
|
||||
padding-right: 0.3em;
|
||||
text-align: center;
|
||||
}
|
||||
#vwRenderer .logEntry > div.canDetails:hover > span:not(:nth-of-type(4)):not(:nth-of-type(8)) {
|
||||
background: rgba(0, 0, 255, 0.1);
|
||||
cursor: zoom-in;
|
||||
}
|
||||
#netInspector:not(.vExpanded) #vwRenderer .logEntry > div > span:nth-of-type(4) {
|
||||
direction: rtl;
|
||||
#netInspector:not(.vExpanded) #vwRenderer .logEntry > .fields > span:nth-of-type(4) {
|
||||
text-align: right;
|
||||
unicode-bidi: plaintext;
|
||||
}
|
||||
#vwRenderer #vwContent .logEntry > div > span:nth-of-type(4) {
|
||||
#vwRenderer #vwContent .logEntry > .fields > span:nth-of-type(4) {
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.vExpanded #vwRenderer #vwContent .logEntry > div > span:nth-of-type(4) {
|
||||
.vExpanded #vwRenderer #vwContent .logEntry > .fields > span:nth-of-type(4) {
|
||||
overflow-y: auto;
|
||||
text-overflow: clip;
|
||||
white-space: pre-line;
|
||||
}
|
||||
#vwRenderer .logEntry > div > span:nth-of-type(5) {
|
||||
#vwRenderer .logEntry > .fields > span:nth-of-type(5) {
|
||||
text-align: center;
|
||||
}
|
||||
/* visual for tabless network requests */
|
||||
#vwRenderer .logEntry > div > span:nth-of-type(5) {
|
||||
#vwRenderer .logEntry > .fields > span:nth-of-type(3),
|
||||
#vwRenderer .logEntry > .fields > span:nth-of-type(5),
|
||||
#vwRenderer .logEntry > .fields > span:nth-of-type(7) {
|
||||
white-space: nowrap !important;
|
||||
}
|
||||
#vwRenderer .logEntry > .fields > span:nth-of-type(8) {
|
||||
position: relative;
|
||||
}
|
||||
#vwRenderer .logEntry > div > span:nth-of-type(7) {
|
||||
}
|
||||
#vwRenderer #vwContent .logEntry > div > span:nth-of-type(7) {
|
||||
}
|
||||
#vwRenderer .logEntry > div > span:nth-of-type(8) {
|
||||
position: relative;
|
||||
}
|
||||
#vwRenderer #vwContent .logEntry > div > span:nth-of-type(8) {
|
||||
#vwRenderer #vwContent .logEntry > .fields > span:nth-of-type(8) {
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.vExpanded #vwRenderer #vwContent .logEntry > div > span:nth-of-type(8) {
|
||||
.vExpanded #vwRenderer #vwContent .logEntry > .fields > span:nth-of-type(8) {
|
||||
overflow-y: auto;
|
||||
white-space: pre-line;
|
||||
}
|
||||
#vwRenderer .logEntry > div > span:nth-of-type(8) b {
|
||||
#vwRenderer .logEntry > .fields > span:nth-of-type(8) b {
|
||||
font-weight: bold;
|
||||
}
|
||||
#vwRenderer .logEntry > div[data-status="1"] > span:nth-of-type(8) b,
|
||||
|
@ -396,37 +387,65 @@ body[dir="rtl"] #vwRenderer .logEntry > div > span:first-child {
|
|||
.netFilteringDialog > .panes > .details > div[data-status="2"] b {
|
||||
background-color: rgb(var(--popup-cell-allow-surface-rgb) / 100%);
|
||||
}
|
||||
#vwRenderer .logEntry > div > span:nth-of-type(8) a {
|
||||
#vwRenderer .logEntry > .fields > span:nth-of-type(8) a {
|
||||
align-items: center;
|
||||
background-color: dimgray;
|
||||
bottom: 0;
|
||||
color: white;
|
||||
display: none;
|
||||
height: 100%;
|
||||
height: min(100%, 1.5em);
|
||||
justify-content: center;
|
||||
padding: 0 0.25em;
|
||||
padding: 0.1em;
|
||||
opacity: 0.4;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
text-decoration: none;
|
||||
top: 0;
|
||||
width: 2rem;
|
||||
width: 1.5em;
|
||||
}
|
||||
#netInspector.vExpanded #vwRenderer .logEntry > div > span:nth-of-type(8) a {
|
||||
#netInspector.vExpanded #vwRenderer .logEntry > .fields > span:nth-of-type(8) a {
|
||||
bottom: 0px;
|
||||
height: unset;
|
||||
padding: 0.25em;
|
||||
padding: 0.2em;
|
||||
top: unset;
|
||||
}
|
||||
#vwRenderer .logEntry > div > span:nth-of-type(8) a::after {
|
||||
#vwRenderer .logEntry > .fields > span:nth-of-type(8) a::after {
|
||||
content: '\2197';
|
||||
}
|
||||
#vwRenderer .logEntry > div.networkRealm > span:nth-of-type(8):hover a {
|
||||
#vwRenderer .logEntry > .fields.networkRealm > span:nth-of-type(8):hover a {
|
||||
display: inline-flex;
|
||||
}
|
||||
#vwRenderer .logEntry > div > span:nth-of-type(8) a:hover {
|
||||
#vwRenderer .logEntry > .fields > span:nth-of-type(8) a:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
@keyframes unrollRow {
|
||||
to {
|
||||
box-shadow: 0 2px 3px 0 #444;
|
||||
height: auto;
|
||||
max-height: 200px;
|
||||
z-index: 1;
|
||||
}
|
||||
}
|
||||
@keyframes unrollRowCell {
|
||||
to {
|
||||
height: auto;
|
||||
overflow-y: auto;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
}
|
||||
#netInspector:not(.vExpanded) #vwRenderer .logEntry:hover {
|
||||
animation-delay: 0.8s;
|
||||
animation-fill-mode: forwards;
|
||||
animation-name: unrollRow;
|
||||
animation-timing-function: step-start;
|
||||
}
|
||||
#netInspector:not(.vExpanded) #vwRenderer .logEntry:hover > .fields > span {
|
||||
animation-delay: 0.8s;
|
||||
animation-fill-mode: forwards;
|
||||
animation-name: unrollRowCell;
|
||||
animation-timing-function: step-start;
|
||||
}
|
||||
|
||||
#vwRenderer #vwBottom {
|
||||
background-color: #00F;
|
||||
height: 0;
|
||||
|
@ -448,6 +467,7 @@ body[dir="rtl"] #vwRenderer .logEntry > div > span:first-child {
|
|||
max-width: 640px;
|
||||
min-width: min(100%, 640px);
|
||||
position: absolute;
|
||||
z-index: 2;
|
||||
}
|
||||
#netInspector .entryTools:empty {
|
||||
display: none;
|
||||
|
|
|
@ -73,6 +73,7 @@ License - https://github.com/FortAwesome/Font-Awesome/tree/a8386aae19e200ddb0f68
|
|||
<symbol id="unlink" viewBox="0 0 1664 1664"><path d="m 439,1271 -256,256 q -11,9 -23,9 -12,0 -23,-9 -9,-10 -9,-23 0,-13 9,-23 l 256,-256 q 10,-9 23,-9 13,0 23,9 9,10 9,23 0,13 -9,23 z m 169,41 v 320 q 0,14 -9,23 -9,9 -23,9 -14,0 -23,-9 -9,-9 -9,-23 v -320 q 0,-14 9,-23 9,-9 23,-9 14,0 23,9 9,9 9,23 z M 384,1088 q 0,14 -9,23 -9,9 -23,9 H 32 q -14,0 -23,-9 -9,-9 -9,-23 0,-14 9,-23 9,-9 23,-9 h 320 q 14,0 23,9 9,9 9,23 z m 1264,128 q 0,120 -85,203 l -147,146 q -83,83 -203,83 -121,0 -204,-85 L 675,1228 q -21,-21 -42,-56 l 239,-18 273,274 q 27,27 68,27.5 41,0.5 68,-26.5 l 147,-146 q 28,-28 28,-67 0,-40 -28,-68 l -274,-275 18,-239 q 35,21 56,42 l 336,336 q 84,86 84,204 z M 1031,492 792,510 519,236 q -28,-28 -68,-28 -39,0 -68,27 L 236,381 q -28,28 -28,67 0,40 28,68 l 274,274 -18,240 q -35,-21 -56,-42 L 100,652 Q 16,566 16,448 16,328 101,245 L 248,99 q 83,-83 203,-83 121,0 204,85 l 334,335 q 21,21 42,56 z m 633,84 q 0,14 -9,23 -9,9 -23,9 h -320 q -14,0 -23,-9 -9,-9 -9,-23 0,-14 9,-23 9,-9 23,-9 h 320 q 14,0 23,9 9,9 9,23 z M 1120,32 v 320 q 0,14 -9,23 -9,9 -23,9 -14,0 -23,-9 -9,-9 -9,-23 V 32 q 0,-14 9,-23 9,-9 23,-9 14,0 23,9 9,9 9,23 z m 407,151 -256,256 q -11,9 -23,9 -12,0 -23,-9 -9,-10 -9,-23 0,-13 9,-23 l 256,-256 q 10,-9 23,-9 13,0 23,9 9,10 9,23 0,13 -9,23 z"/></symbol>
|
||||
<symbol id="unlock-alt" viewBox="0 0 1152 1536"><path d="m 1056,768 q 40,0 68,28 28,28 28,68 v 576 q 0,40 -28,68 -28,28 -68,28 H 96 Q 56,1536 28,1508 0,1480 0,1440 V 864 q 0,-40 28,-68 28,-28 68,-28 h 32 V 448 Q 128,263 259.5,131.5 391,0 576,0 761,0 892.5,131.5 1024,263 1024,448 q 0,26 -19,45 -19,19 -45,19 h -64 q -26,0 -45,-19 -19,-19 -19,-45 0,-106 -75,-181 -75,-75 -181,-75 -106,0 -181,75 -75,75 -75,181 v 320 z"/></symbol>
|
||||
<symbol id="upload_alt" viewBox="0 0 1664 1600"><path d="m 1280,1408 q 0,-26 -19,-45 -19,-19 -45,-19 -26,0 -45,19 -19,19 -19,45 0,26 19,45 19,19 45,19 26,0 45,-19 19,-19 19,-45 z m 256,0 q 0,-26 -19,-45 -19,-19 -45,-19 -26,0 -45,19 -19,19 -19,45 0,26 19,45 19,19 45,19 26,0 45,-19 19,-19 19,-45 z m 128,-224 v 320 q 0,40 -28,68 -28,28 -68,28 H 96 q -40,0 -68,-28 -28,-28 -28,-68 v -320 q 0,-40 28,-68 28,-28 68,-28 h 427 q 21,56 70.5,92 49.5,36 110.5,36 h 256 q 61,0 110.5,-36 49.5,-36 70.5,-92 h 427 q 40,0 68,28 28,28 28,68 z M 1339,536 q -17,40 -59,40 h -256 v 448 q 0,26 -19,45 -19,19 -45,19 H 704 q -26,0 -45,-19 -19,-19 -19,-45 V 576 H 384 q -42,0 -59,-40 -17,-39 14,-69 L 787,19 q 18,-19 45,-19 27,0 45,19 l 448,448 q 31,30 14,69 z"/></symbol>
|
||||
<symbol id="volume-up" viewBox="0 0 1664 1422"><path d="m 768,167 v 1088 c 0,35 -29,64 -64,64 -17,0 -33,-7 -45,-19 L 326,967 H 64 C 29,967 0,938 0,903 V 519 C 0,484 29,455 64,455 H 326 L 659,122 c 12,-12 28,-19 45,-19 35,0 64,29 64,64 z m 384,544 c 0,100 -61,197 -155,235 -8,4 -17,5 -25,5 -35,0 -64,-28 -64,-64 0,-76 116,-55 116,-176 0,-121 -116,-100 -116,-176 0,-36 29,-64 64,-64 8,0 17,1 25,5 94,37 155,135 155,235 z m 256,0 c 0,203 -122,392 -310,471 -8,3 -17,5 -25,5 -36,0 -65,-29 -65,-64 0,-28 16,-47 39,-59 27,-14 52,-26 76,-44 99,-72 157,-187 157,-309 0,-122 -58,-237 -157,-309 -24,-18 -49,-30 -76,-44 -23,-12 -39,-31 -39,-59 0,-35 29,-64 64,-64 9,0 18,2 26,5 188,79 310,268 310,471 z m 256,0 c 0,307 -183,585 -465,706 -8,3 -17,5 -26,5 -35,0 -64,-29 -64,-64 0,-29 15,-45 39,-59 14,-8 30,-13 45,-21 28,-15 56,-32 82,-51 164,-121 261,-312 261,-516 0,-204 -97,-395 -261,-516 -26,-19 -54,-36 -82,-51 -15,-8 -31,-13 -45,-21 -24,-14 -39,-30 -39,-59 0,-35 29,-64 64,-64 9,0 18,2 26,5 282,121 465,399 465,706 z"/></symbol>
|
||||
<symbol id="zoom-in" viewBox="0 0 1664 1664"><path d="m 1024,672 v 64 q 0,13 -9.5,22.5 Q 1005,768 992,768 H 768 v 224 q 0,13 -9.5,22.5 -9.5,9.5 -22.5,9.5 h -64 q -13,0 -22.5,-9.5 Q 640,1005 640,992 V 768 H 416 q -13,0 -22.5,-9.5 Q 384,749 384,736 v -64 q 0,-13 9.5,-22.5 Q 403,640 416,640 H 640 V 416 q 0,-13 9.5,-22.5 Q 659,384 672,384 h 64 q 13,0 22.5,9.5 9.5,9.5 9.5,22.5 v 224 h 224 q 13,0 22.5,9.5 9.5,9.5 9.5,22.5 z m 128,32 Q 1152,519 1020.5,387.5 889,256 704,256 519,256 387.5,387.5 256,519 256,704 256,889 387.5,1020.5 519,1152 704,1152 889,1152 1020.5,1020.5 1152,889 1152,704 Z m 512,832 q 0,53 -37.5,90.5 -37.5,37.5 -90.5,37.5 -54,0 -90,-38 L 1103,1284 Q 924,1408 704,1408 561,1408 430.5,1352.5 300,1297 205.5,1202.5 111,1108 55.5,977.5 0,847 0,704 0,561 55.5,430.5 111,300 205.5,205.5 300,111 430.5,55.5 561,0 704,0 q 143,0 273.5,55.5 130.5,55.5 225,150 94.5,94.5 150,225 55.5,130.5 55.5,273.5 0,220 -124,399 l 343,343 q 37,37 37,90 z"/></symbol>
|
||||
<symbol id="zoom-out" viewBox="0 0 1664 1664"><path d="m 1024,672 v 64 q 0,13 -9.5,22.5 Q 1005,768 992,768 H 416 q -13,0 -22.5,-9.5 Q 384,749 384,736 v -64 q 0,-13 9.5,-22.5 Q 403,640 416,640 h 576 q 13,0 22.5,9.5 9.5,9.5 9.5,22.5 z m 128,32 Q 1152,519 1020.5,387.5 889,256 704,256 519,256 387.5,387.5 256,519 256,704 256,889 387.5,1020.5 519,1152 704,1152 889,1152 1020.5,1020.5 1152,889 1152,704 Z m 512,832 q 0,53 -37.5,90.5 -37.5,37.5 -90.5,37.5 -54,0 -90,-38 L 1103,1284 Q 924,1408 704,1408 561,1408 430.5,1352.5 300,1297 205.5,1202.5 111,1108 55.5,977.5 0,847 0,704 0,561 55.5,430.5 111,300 205.5,205.5 300,111 430.5,55.5 561,0 704,0 q 143,0 273.5,55.5 130.5,55.5 225,150 94.5,94.5 150,225 55.5,130.5 55.5,273.5 0,220 -124,399 l 343,343 q 37,37 37,90 z"/></symbol>
|
||||
</defs>
|
||||
|
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 38 KiB |
|
@ -374,7 +374,7 @@ const µBlock = { // jshint ignore:line
|
|||
toLogger() {
|
||||
const details = {
|
||||
id: this.id,
|
||||
tstamp: Date.now(),
|
||||
tstamp: 0,
|
||||
realm: this.realm,
|
||||
method: this.getMethodName(),
|
||||
type: this.stype,
|
||||
|
|
|
@ -353,6 +353,7 @@ const loadBenchmarkDataset = (( ) => {
|
|||
hostname: '',
|
||||
tabId: 0,
|
||||
url: '',
|
||||
nocache: true,
|
||||
};
|
||||
let count = 0;
|
||||
const t0 = performance.now();
|
||||
|
|
|
@ -49,9 +49,8 @@ document.body.addEventListener('click', ev => {
|
|||
what: 'clickToLoad',
|
||||
frameURL,
|
||||
}).then(ok => {
|
||||
if ( ok ) {
|
||||
if ( ok !== true ) { return; }
|
||||
self.location.replace(frameURL);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -460,28 +460,6 @@ vAPI.SafeAnimationFrame = class {
|
|||
vAPI.domWatcher = { start, addListener, removeListener };
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/******************************************************************************/
|
||||
/******************************************************************************/
|
||||
|
||||
vAPI.injectScriptlet = function(doc, text) {
|
||||
if ( !doc ) { return; }
|
||||
let script, url;
|
||||
try {
|
||||
const blob = new self.Blob([ text ], { type: 'text/javascript; charset=utf-8' });
|
||||
url = self.URL.createObjectURL(blob);
|
||||
script = doc.createElement('script');
|
||||
script.async = false;
|
||||
script.src = url;
|
||||
(doc.head || doc.documentElement || doc).appendChild(script);
|
||||
} catch (ex) {
|
||||
}
|
||||
if ( url ) {
|
||||
if ( script ) { script.remove(); }
|
||||
self.URL.revokeObjectURL(url);
|
||||
}
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
/******************************************************************************/
|
||||
/*******************************************************************************
|
||||
|
@ -1298,7 +1276,6 @@ vAPI.DOMFilterer = class {
|
|||
const {
|
||||
noSpecificCosmeticFiltering,
|
||||
noGenericCosmeticFiltering,
|
||||
scriptletDetails,
|
||||
} = response;
|
||||
|
||||
vAPI.noSpecificCosmeticFiltering = noSpecificCosmeticFiltering;
|
||||
|
@ -1320,14 +1297,6 @@ vAPI.DOMFilterer = class {
|
|||
vAPI.userStylesheet.apply();
|
||||
}
|
||||
|
||||
if ( scriptletDetails && typeof self.uBO_scriptletsInjected !== 'string' ) {
|
||||
self.uBO_scriptletsInjected = scriptletDetails.filters;
|
||||
if ( scriptletDetails.mainWorld ) {
|
||||
vAPI.injectScriptlet(document, scriptletDetails.mainWorld);
|
||||
vAPI.injectedScripts = scriptletDetails.mainWorld;
|
||||
}
|
||||
}
|
||||
|
||||
if ( vAPI.domSurveyor ) {
|
||||
if ( Array.isArray(cfeDetails.genericCosmeticHashes) ) {
|
||||
vAPI.domSurveyor.addHashes(cfeDetails.genericCosmeticHashes);
|
||||
|
|
|
@ -78,6 +78,7 @@ export const faIconsInit = (( ) => {
|
|||
[ 'unlink', { viewBox: '0 0 1664 1664', path: 'm 439,1271 -256,256 q -11,9 -23,9 -12,0 -23,-9 -9,-10 -9,-23 0,-13 9,-23 l 256,-256 q 10,-9 23,-9 13,0 23,9 9,10 9,23 0,13 -9,23 z m 169,41 v 320 q 0,14 -9,23 -9,9 -23,9 -14,0 -23,-9 -9,-9 -9,-23 v -320 q 0,-14 9,-23 9,-9 23,-9 14,0 23,9 9,9 9,23 z M 384,1088 q 0,14 -9,23 -9,9 -23,9 H 32 q -14,0 -23,-9 -9,-9 -9,-23 0,-14 9,-23 9,-9 23,-9 h 320 q 14,0 23,9 9,9 9,23 z m 1264,128 q 0,120 -85,203 l -147,146 q -83,83 -203,83 -121,0 -204,-85 L 675,1228 q -21,-21 -42,-56 l 239,-18 273,274 q 27,27 68,27.5 41,0.5 68,-26.5 l 147,-146 q 28,-28 28,-67 0,-40 -28,-68 l -274,-275 18,-239 q 35,21 56,42 l 336,336 q 84,86 84,204 z M 1031,492 792,510 519,236 q -28,-28 -68,-28 -39,0 -68,27 L 236,381 q -28,28 -28,67 0,40 28,68 l 274,274 -18,240 q -35,-21 -56,-42 L 100,652 Q 16,566 16,448 16,328 101,245 L 248,99 q 83,-83 203,-83 121,0 204,85 l 334,335 q 21,21 42,56 z m 633,84 q 0,14 -9,23 -9,9 -23,9 h -320 q -14,0 -23,-9 -9,-9 -9,-23 0,-14 9,-23 9,-9 23,-9 h 320 q 14,0 23,9 9,9 9,23 z M 1120,32 v 320 q 0,14 -9,23 -9,9 -23,9 -14,0 -23,-9 -9,-9 -9,-23 V 32 q 0,-14 9,-23 9,-9 23,-9 14,0 23,9 9,9 9,23 z m 407,151 -256,256 q -11,9 -23,9 -12,0 -23,-9 -9,-10 -9,-23 0,-13 9,-23 l 256,-256 q 10,-9 23,-9 13,0 23,9 9,10 9,23 0,13 -9,23 z' } ],
|
||||
[ 'unlock-alt', { viewBox: '0 0 1152 1536', path: 'm 1056,768 q 40,0 68,28 28,28 28,68 v 576 q 0,40 -28,68 -28,28 -68,28 H 96 Q 56,1536 28,1508 0,1480 0,1440 V 864 q 0,-40 28,-68 28,-28 68,-28 h 32 V 448 Q 128,263 259.5,131.5 391,0 576,0 761,0 892.5,131.5 1024,263 1024,448 q 0,26 -19,45 -19,19 -45,19 h -64 q -26,0 -45,-19 -19,-19 -19,-45 0,-106 -75,-181 -75,-75 -181,-75 -106,0 -181,75 -75,75 -75,181 v 320 z' } ],
|
||||
[ 'upload-alt', { viewBox: '0 0 1664 1600', path: 'm 1280,1408 q 0,-26 -19,-45 -19,-19 -45,-19 -26,0 -45,19 -19,19 -19,45 0,26 19,45 19,19 45,19 26,0 45,-19 19,-19 19,-45 z m 256,0 q 0,-26 -19,-45 -19,-19 -45,-19 -26,0 -45,19 -19,19 -19,45 0,26 19,45 19,19 45,19 26,0 45,-19 19,-19 19,-45 z m 128,-224 v 320 q 0,40 -28,68 -28,28 -68,28 H 96 q -40,0 -68,-28 -28,-28 -28,-68 v -320 q 0,-40 28,-68 28,-28 68,-28 h 427 q 21,56 70.5,92 49.5,36 110.5,36 h 256 q 61,0 110.5,-36 49.5,-36 70.5,-92 h 427 q 40,0 68,28 28,28 28,68 z M 1339,536 q -17,40 -59,40 h -256 v 448 q 0,26 -19,45 -19,19 -45,19 H 704 q -26,0 -45,-19 -19,-19 -19,-45 V 576 H 384 q -42,0 -59,-40 -17,-39 14,-69 L 787,19 q 18,-19 45,-19 27,0 45,19 l 448,448 q 31,30 14,69 z' } ],
|
||||
[ 'volume-up', { viewBox: '0 0 1664 1422', path: 'm 768,167 v 1088 c 0,35 -29,64 -64,64 -17,0 -33,-7 -45,-19 L 326,967 H 64 C 29,967 0,938 0,903 V 519 C 0,484 29,455 64,455 H 326 L 659,122 c 12,-12 28,-19 45,-19 35,0 64,29 64,64 z m 384,544 c 0,100 -61,197 -155,235 -8,4 -17,5 -25,5 -35,0 -64,-28 -64,-64 0,-76 116,-55 116,-176 0,-121 -116,-100 -116,-176 0,-36 29,-64 64,-64 8,0 17,1 25,5 94,37 155,135 155,235 z m 256,0 c 0,203 -122,392 -310,471 -8,3 -17,5 -25,5 -36,0 -65,-29 -65,-64 0,-28 16,-47 39,-59 27,-14 52,-26 76,-44 99,-72 157,-187 157,-309 0,-122 -58,-237 -157,-309 -24,-18 -49,-30 -76,-44 -23,-12 -39,-31 -39,-59 0,-35 29,-64 64,-64 9,0 18,2 26,5 188,79 310,268 310,471 z m 256,0 c 0,307 -183,585 -465,706 -8,3 -17,5 -26,5 -35,0 -64,-29 -64,-64 0,-29 15,-45 39,-59 14,-8 30,-13 45,-21 28,-15 56,-32 82,-51 164,-121 261,-312 261,-516 0,-204 -97,-395 -261,-516 -26,-19 -54,-36 -82,-51 -15,-8 -31,-13 -45,-21 -24,-14 -39,-30 -39,-59 0,-35 29,-64 64,-64 9,0 18,2 26,5 282,121 465,399 465,706 z' } ],
|
||||
[ 'zoom-in', { viewBox: '0 0 1664 1664', path: 'm 1024,672 v 64 q 0,13 -9.5,22.5 Q 1005,768 992,768 H 768 v 224 q 0,13 -9.5,22.5 -9.5,9.5 -22.5,9.5 h -64 q -13,0 -22.5,-9.5 Q 640,1005 640,992 V 768 H 416 q -13,0 -22.5,-9.5 Q 384,749 384,736 v -64 q 0,-13 9.5,-22.5 Q 403,640 416,640 H 640 V 416 q 0,-13 9.5,-22.5 Q 659,384 672,384 h 64 q 13,0 22.5,9.5 9.5,9.5 9.5,22.5 v 224 h 224 q 13,0 22.5,9.5 9.5,9.5 9.5,22.5 z m 128,32 Q 1152,519 1020.5,387.5 889,256 704,256 519,256 387.5,387.5 256,519 256,704 256,889 387.5,1020.5 519,1152 704,1152 889,1152 1020.5,1020.5 1152,889 1152,704 Z m 512,832 q 0,53 -37.5,90.5 -37.5,37.5 -90.5,37.5 -54,0 -90,-38 L 1103,1284 Q 924,1408 704,1408 561,1408 430.5,1352.5 300,1297 205.5,1202.5 111,1108 55.5,977.5 0,847 0,704 0,561 55.5,430.5 111,300 205.5,205.5 300,111 430.5,55.5 561,0 704,0 q 143,0 273.5,55.5 130.5,55.5 225,150 94.5,94.5 150,225 55.5,130.5 55.5,273.5 0,220 -124,399 l 343,343 q 37,37 37,90 z' } ],
|
||||
[ 'zoom-out', { viewBox: '0 0 1664 1664', path: 'm 1024,672 v 64 q 0,13 -9.5,22.5 Q 1005,768 992,768 H 416 q -13,0 -22.5,-9.5 Q 384,749 384,736 v -64 q 0,-13 9.5,-22.5 Q 403,640 416,640 h 576 q 13,0 22.5,9.5 9.5,9.5 9.5,22.5 z m 128,32 Q 1152,519 1020.5,387.5 889,256 704,256 519,256 387.5,387.5 256,519 256,704 256,889 387.5,1020.5 519,1152 704,1152 889,1152 1020.5,1020.5 1152,889 1152,704 Z m 512,832 q 0,53 -37.5,90.5 -37.5,37.5 -90.5,37.5 -54,0 -90,-38 L 1103,1284 Q 924,1408 704,1408 561,1408 430.5,1352.5 300,1297 205.5,1202.5 111,1108 55.5,977.5 0,847 0,704 0,561 55.5,430.5 111,300 205.5,205.5 300,111 430.5,55.5 561,0 704,0 q 143,0 273.5,55.5 130.5,55.5 225,150 94.5,94.5 150,225 55.5,130.5 55.5,273.5 0,220 -124,399 l 343,343 q 37,37 37,90 z' } ],
|
||||
// See /img/photon.svg
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
import webext from './webext.js';
|
||||
import { hostnameFromURI } from './uri-utils.js';
|
||||
import { i18n, i18n$ } from './i18n.js';
|
||||
import { dom, qs$, qsa$ } from './dom.js';
|
||||
|
@ -33,7 +34,7 @@ import { dom, qs$, qsa$ } from './dom.js';
|
|||
const messaging = vAPI.messaging;
|
||||
const logger = self.logger = { ownerId: Date.now() };
|
||||
const logDate = new Date();
|
||||
const logDateTimezoneOffset = logDate.getTimezoneOffset() * 60000;
|
||||
const logDateTimezoneOffset = logDate.getTimezoneOffset() * 60;
|
||||
const loggerEntries = [];
|
||||
|
||||
const COLUMN_TIMESTAMP = 0;
|
||||
|
@ -368,7 +369,7 @@ const createLogSeparator = function(details, text) {
|
|||
separator.textContent = '';
|
||||
|
||||
const textContent = [];
|
||||
logDate.setTime(separator.tstamp - logDateTimezoneOffset);
|
||||
logDate.setTime((separator.tstamp - logDateTimezoneOffset) * 1000);
|
||||
textContent.push(
|
||||
// cell 0
|
||||
padTo2(logDate.getUTCHours()) + ':' +
|
||||
|
@ -464,7 +465,7 @@ const parseLogEntry = function(details) {
|
|||
const textContent = [];
|
||||
|
||||
// Cell 0
|
||||
logDate.setTime(details.tstamp - logDateTimezoneOffset);
|
||||
logDate.setTime((details.tstamp - logDateTimezoneOffset) * 1000);
|
||||
textContent.push(
|
||||
padTo2(logDate.getUTCHours()) + ':' +
|
||||
padTo2(logDate.getUTCMinutes()) + ':' +
|
||||
|
@ -474,7 +475,13 @@ const parseLogEntry = function(details) {
|
|||
// Cell 1
|
||||
if ( details.realm === 'message' ) {
|
||||
textContent.push(details.text);
|
||||
entry.textContent = textContent.join('\x1F');
|
||||
if ( details.type ) {
|
||||
textContent.push(details.type);
|
||||
}
|
||||
if ( details.keywords ) {
|
||||
textContent.push(...details.keywords);
|
||||
}
|
||||
entry.textContent = textContent.join('\x1F') + '\x1F';
|
||||
return entry;
|
||||
}
|
||||
|
||||
|
@ -2052,12 +2059,30 @@ dom.on(document, 'keydown', ev => {
|
|||
}
|
||||
});
|
||||
|
||||
dom.on(
|
||||
'#netInspector',
|
||||
'click',
|
||||
'.canDetails > span:not(:nth-of-type(4)):not(:nth-of-type(8))',
|
||||
ev => { toggleOn(ev); }
|
||||
);
|
||||
// This is to detect text selection, in which case the click won't be
|
||||
// interpreted as a request to open the details of the entry.
|
||||
let selectionAtMouseDown;
|
||||
let selectionAtTimer;
|
||||
dom.on('#netInspector', 'mousedown', '.canDetails *', ev => {
|
||||
if ( ev.button !== 0 ) { return; }
|
||||
if ( selectionAtMouseDown !== undefined ) { return; }
|
||||
selectionAtMouseDown = document.getSelection().toString();
|
||||
});
|
||||
|
||||
dom.on('#netInspector', 'click', '.canDetails *', ev => {
|
||||
if ( ev.button !== 0 ) { return; }
|
||||
if ( selectionAtTimer !== undefined ) {
|
||||
clearTimeout(selectionAtTimer);
|
||||
}
|
||||
selectionAtTimer = setTimeout(( ) => {
|
||||
selectionAtTimer = undefined;
|
||||
const selectionAsOfNow = document.getSelection().toString();
|
||||
const selectionHasChanged = selectionAsOfNow !== selectionAtMouseDown;
|
||||
selectionAtMouseDown = undefined;
|
||||
if ( selectionHasChanged && selectionAsOfNow !== '' ) { return; }
|
||||
toggleOn(ev);
|
||||
}, 333);
|
||||
});
|
||||
|
||||
dom.on(
|
||||
'#netInspector',
|
||||
|
@ -2149,16 +2174,12 @@ const rowFilterer = (( ) => {
|
|||
filters = builtinFilters.concat(userFilters);
|
||||
};
|
||||
|
||||
const filterOne = function(logEntry) {
|
||||
if (
|
||||
logEntry.dead ||
|
||||
selectedTabId !== 0 &&
|
||||
(
|
||||
logEntry.tabId === undefined ||
|
||||
logEntry.tabId > 0 && logEntry.tabId !== selectedTabId
|
||||
)
|
||||
) {
|
||||
return false;
|
||||
const filterOne = logEntry => {
|
||||
if ( logEntry.dead ) { return false; }
|
||||
if ( selectedTabId !== 0 ) {
|
||||
if ( logEntry.tabId !== undefined && logEntry.tabId > 0 ) {
|
||||
if (logEntry.tabId !== selectedTabId ) { return false; }
|
||||
}
|
||||
}
|
||||
|
||||
if ( masterFilterSwitch === false || filters.length === 0 ) {
|
||||
|
@ -2303,7 +2324,7 @@ const rowJanitor = (( ) => {
|
|||
? opts.maxEntryCount
|
||||
: 0;
|
||||
const obsolete = typeof opts.maxAge === 'number'
|
||||
? Date.now() - opts.maxAge * 60000
|
||||
? Date.now() / 1000 - opts.maxAge * 60
|
||||
: 0;
|
||||
|
||||
let i = rowIndex;
|
||||
|
@ -2686,7 +2707,7 @@ const loggerStats = (( ) => {
|
|||
if ( beg === 0 ) { continue; }
|
||||
let timeField = text.slice(0, beg);
|
||||
if ( options.time === 'anonymous' ) {
|
||||
timeField = '+' + Math.round((entry.tstamp - t0) / 1000).toString();
|
||||
timeField = '+' + Math.round(entry.tstamp - t0).toString();
|
||||
}
|
||||
fields.push(timeField);
|
||||
beg += 1;
|
||||
|
@ -3020,6 +3041,24 @@ dom.on('#pageSelector', 'change', pageSelectorChanged);
|
|||
dom.on('#netInspector .vCompactToggler', 'click', toggleVCompactView);
|
||||
dom.on('#pause', 'click', pauseNetInspector);
|
||||
|
||||
dom.on('#logLevel', 'click', ev => {
|
||||
const level = dom.cl.toggle(ev.currentTarget, 'active') ? 2 : 1;
|
||||
webext.tabs.query({
|
||||
discarded: false,
|
||||
url: [ 'http://*/*', 'https://*/*' ],
|
||||
}).then(tabs => {
|
||||
for ( const tab of tabs ) {
|
||||
const { status } = tab;
|
||||
if ( status !== 'loading' && status !== 'complete' ) { continue; }
|
||||
webext.tabs.executeScript(tab.id, {
|
||||
allFrames: true,
|
||||
file: `/js/scriptlets/scriptlet-loglevel-${level}.js`,
|
||||
matchAboutBlank: true,
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
dom.on('#netInspector', 'copy', ev => {
|
||||
const selection = document.getSelection();
|
||||
ev.clipboardData.setData('text/plain',
|
||||
|
|
|
@ -23,13 +23,14 @@
|
|||
|
||||
/******************************************************************************/
|
||||
|
||||
import { broadcastToAll } from './broadcast.js';
|
||||
import { broadcast, broadcastToAll } from './broadcast.js';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
let buffer = null;
|
||||
let lastReadTime = 0;
|
||||
let writePtr = 0;
|
||||
let lastBoxedEntry = '';
|
||||
|
||||
// After 30 seconds without being read, the logger buffer will be considered
|
||||
// unused, and thus disabled.
|
||||
|
@ -43,36 +44,48 @@ const janitorTimer = vAPI.defer.create(( ) => {
|
|||
logger.enabled = false;
|
||||
buffer = null;
|
||||
writePtr = 0;
|
||||
lastBoxedEntry = '';
|
||||
logger.ownerId = undefined;
|
||||
broadcastToAll({ what: 'loggerDisabled' });
|
||||
});
|
||||
|
||||
const boxEntry = function(details) {
|
||||
if ( details.tstamp === undefined ) {
|
||||
details.tstamp = Date.now();
|
||||
}
|
||||
const boxEntry = details => {
|
||||
details.tstamp = Date.now() / 1000 | 0;
|
||||
return JSON.stringify(details);
|
||||
};
|
||||
|
||||
const logger = {
|
||||
enabled: false,
|
||||
ownerId: undefined,
|
||||
writeOne: function(details) {
|
||||
if ( buffer === null ) { return; }
|
||||
const box = boxEntry(details);
|
||||
const pushOne = box => {
|
||||
if ( writePtr === buffer.length ) {
|
||||
buffer.push(box);
|
||||
} else {
|
||||
buffer[writePtr] = box;
|
||||
}
|
||||
writePtr += 1;
|
||||
};
|
||||
|
||||
const logger = {
|
||||
enabled: false,
|
||||
ownerId: undefined,
|
||||
writeOne(details) {
|
||||
if ( buffer === null ) { return; }
|
||||
const box = boxEntry(details);
|
||||
if ( box === lastBoxedEntry ) { return; }
|
||||
if ( lastBoxedEntry !== '' ) {
|
||||
pushOne(lastBoxedEntry);
|
||||
}
|
||||
lastBoxedEntry = box;
|
||||
},
|
||||
readAll: function(ownerId) {
|
||||
readAll(ownerId) {
|
||||
this.ownerId = ownerId;
|
||||
if ( buffer === null ) {
|
||||
this.enabled = true;
|
||||
buffer = [];
|
||||
janitorTimer.on(logBufferObsoleteAfter);
|
||||
broadcast({ what: 'loggerEnabled' });
|
||||
}
|
||||
if ( lastBoxedEntry !== '' ) {
|
||||
pushOne(lastBoxedEntry);
|
||||
lastBoxedEntry = '';
|
||||
}
|
||||
const out = buffer.slice(0, writePtr);
|
||||
writePtr = 0;
|
||||
|
|
|
@ -716,14 +716,14 @@ const retrieveContentScriptParameters = async function(sender, request) {
|
|||
// https://github.com/uBlockOrigin/uBlock-issues/issues/688#issuecomment-748179731
|
||||
// For non-network URIs, scriptlet injection is deferred to here. The
|
||||
// effective URL is available here in `request.url`.
|
||||
if ( logger.enabled || request.needScriptlets ) {
|
||||
const scriptletDetails = scriptletFilteringEngine.injectNow(request);
|
||||
if ( logger.enabled ) {
|
||||
const scriptletDetails = scriptletFilteringEngine.retrieve(request);
|
||||
if ( scriptletDetails !== undefined ) {
|
||||
scriptletFilteringEngine.toLogger(request, scriptletDetails);
|
||||
}
|
||||
}
|
||||
if ( request.needScriptlets ) {
|
||||
response.scriptletDetails = scriptletDetails;
|
||||
}
|
||||
}
|
||||
scriptletFilteringEngine.injectNow(request);
|
||||
}
|
||||
|
||||
// https://github.com/NanoMeow/QuickReports/issues/6#issuecomment-414516623
|
||||
|
@ -796,6 +796,17 @@ const onMessage = function(request, sender, callback) {
|
|||
µb.maybeGoodPopup.url = request.url;
|
||||
break;
|
||||
|
||||
case 'messageToLogger':
|
||||
if ( logger.enabled !== true ) { break; }
|
||||
logger.writeOne({
|
||||
tabId: sender.tabId,
|
||||
realm: 'message',
|
||||
type: request.type || 'info',
|
||||
keywords: [ 'scriptlet' ],
|
||||
text: request.text,
|
||||
});
|
||||
break;
|
||||
|
||||
case 'shouldRenderNoscriptTags':
|
||||
if ( pageStore === null ) { break; }
|
||||
const fctxt = µb.filteringContext.fromTabId(sender.tabId);
|
||||
|
|
|
@ -265,10 +265,10 @@ export class ScriptletFilteringEngine {
|
|||
}
|
||||
}
|
||||
|
||||
const scriptletGlobals = options.scriptletGlobals || [];
|
||||
const scriptletGlobals = options.scriptletGlobals || {};
|
||||
|
||||
if ( options.debug ) {
|
||||
scriptletGlobals.push([ 'canDebug', true ]);
|
||||
scriptletGlobals.canDebug = true;
|
||||
}
|
||||
|
||||
return {
|
||||
|
@ -279,7 +279,7 @@ export class ScriptletFilteringEngine {
|
|||
options.debugScriptlets ? 'debugger;' : ';',
|
||||
'',
|
||||
// For use by scriptlets to share local data among themselves
|
||||
`const scriptletGlobals = new Map(${JSON.stringify(scriptletGlobals, null, 2)});`,
|
||||
`const scriptletGlobals = ${JSON.stringify(scriptletGlobals, null, 4)}`,
|
||||
'',
|
||||
scriptletDetails.mainWorld,
|
||||
'',
|
||||
|
@ -293,7 +293,7 @@ export class ScriptletFilteringEngine {
|
|||
options.debugScriptlets ? 'debugger;' : ';',
|
||||
'',
|
||||
// For use by scriptlets to share local data among themselves
|
||||
`const scriptletGlobals = new Map(${JSON.stringify(scriptletGlobals, null, 2)});`,
|
||||
`const scriptletGlobals = ${JSON.stringify(scriptletGlobals, null, 4)}`,
|
||||
'',
|
||||
scriptletDetails.isolatedWorld,
|
||||
'',
|
||||
|
|
|
@ -44,16 +44,6 @@ import {
|
|||
const contentScriptRegisterer = new (class {
|
||||
constructor() {
|
||||
this.hostnameToDetails = new Map();
|
||||
if ( browser.contentScripts === undefined ) { return; }
|
||||
this.bc = onBroadcast(msg => {
|
||||
if ( msg.what !== 'filteringBehaviorChanged' ) { return; }
|
||||
const direction = msg.direction || 0;
|
||||
if ( direction > 0 ) { return; }
|
||||
if ( direction >= 0 && msg.hostname ) {
|
||||
return this.flush(msg.hostname);
|
||||
}
|
||||
this.reset();
|
||||
});
|
||||
}
|
||||
register(hostname, code) {
|
||||
if ( browser.contentScripts === undefined ) { return false; }
|
||||
|
@ -133,16 +123,15 @@ const mainWorldInjector = (( ) => {
|
|||
'json-slot',
|
||||
');',
|
||||
];
|
||||
const jsonSlot = parts.indexOf('json-slot');
|
||||
return {
|
||||
parts,
|
||||
jsonSlot: parts.indexOf('json-slot'),
|
||||
assemble: function(hostname, scriptlets, filters) {
|
||||
this.parts[this.jsonSlot] = JSON.stringify({
|
||||
assemble: function(hostname, details) {
|
||||
parts[jsonSlot] = JSON.stringify({
|
||||
hostname,
|
||||
scriptlets,
|
||||
filters,
|
||||
scriptlets: details.mainWorld,
|
||||
filters: details.filters,
|
||||
});
|
||||
return this.parts.join('');
|
||||
return parts.join('');
|
||||
},
|
||||
};
|
||||
})();
|
||||
|
@ -165,24 +154,53 @@ const isolatedWorldInjector = (( ) => {
|
|||
'json-slot',
|
||||
');',
|
||||
];
|
||||
const jsonSlot = parts.indexOf('json-slot');
|
||||
return {
|
||||
parts,
|
||||
jsonSlot: parts.indexOf('json-slot'),
|
||||
assemble: function(hostname, scriptlets) {
|
||||
this.parts[this.jsonSlot] = JSON.stringify({ hostname });
|
||||
const code = this.parts.join('');
|
||||
assemble(hostname, details) {
|
||||
parts[jsonSlot] = JSON.stringify({ hostname });
|
||||
const code = parts.join('');
|
||||
// Manually substitute noop function with scriptlet wrapper
|
||||
// function, so as to not suffer instances of special
|
||||
// replacement characters `$`,`\` when using String.replace()
|
||||
// with scriptlet code.
|
||||
const match = /function\(\)\{\}/.exec(code);
|
||||
return code.slice(0, match.index) +
|
||||
scriptlets +
|
||||
details.isolatedWorld +
|
||||
code.slice(match.index + match[0].length);
|
||||
},
|
||||
};
|
||||
})();
|
||||
|
||||
const onScriptletMessageInjector = (( ) => {
|
||||
const parts = [
|
||||
'(',
|
||||
function(name) {
|
||||
if ( typeof vAPI !== 'object' ) { return; }
|
||||
if ( vAPI === null ) { return; }
|
||||
if ( vAPI.bcSecret ) { return; }
|
||||
const bcSecret = new self.BroadcastChannel(name);
|
||||
bcSecret.onmessage = ev => {
|
||||
if ( self.vAPI && self.vAPI.messaging ) {
|
||||
self.vAPI.messaging.send('contentscript', ev.data);
|
||||
} else {
|
||||
bcSecret.onmessage = null;
|
||||
}
|
||||
};
|
||||
vAPI.bcSecret = bcSecret;
|
||||
}.toString(),
|
||||
')(',
|
||||
'bcSecret-slot',
|
||||
');',
|
||||
];
|
||||
const bcSecretSlot = parts.indexOf('bcSecret-slot');
|
||||
return {
|
||||
assemble(details) {
|
||||
parts[bcSecretSlot] = JSON.stringify(details.bcSecret);
|
||||
return parts.join('\n');
|
||||
},
|
||||
};
|
||||
})();
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
export class ScriptletFilteringEngineEx extends ScriptletFilteringEngine {
|
||||
|
@ -192,10 +210,26 @@ export class ScriptletFilteringEngineEx extends ScriptletFilteringEngine {
|
|||
this.warSecret = undefined;
|
||||
this.scriptletCache = new MRUCache(32);
|
||||
this.isDevBuild = undefined;
|
||||
onBroadcast(msg => {
|
||||
if ( msg.what !== 'hiddenSettingsChanged' ) { return; }
|
||||
this.scriptletCache.reset();
|
||||
this.bc = onBroadcast(msg => {
|
||||
switch ( msg.what ) {
|
||||
case 'filteringBehaviorChanged': {
|
||||
const direction = msg.direction || 0;
|
||||
if ( direction > 0 ) { return; }
|
||||
if ( direction >= 0 && msg.hostname ) {
|
||||
return contentScriptRegisterer.flush(msg.hostname);
|
||||
}
|
||||
contentScriptRegisterer.reset();
|
||||
break;
|
||||
}
|
||||
case 'hiddenSettingsChanged':
|
||||
this.isDevBuild = undefined;
|
||||
/* fall through */
|
||||
case 'loggerEnabled':
|
||||
case 'loggerDisabled':
|
||||
this.scriptletCache.reset();
|
||||
contentScriptRegisterer.reset();
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -243,58 +277,82 @@ export class ScriptletFilteringEngineEx extends ScriptletFilteringEngine {
|
|||
this.warSecret = vAPI.warSecret.long();
|
||||
}
|
||||
|
||||
const bcSecret = vAPI.generateSecret(3);
|
||||
|
||||
const options = {
|
||||
scriptletGlobals: [
|
||||
[ 'warOrigin', this.warOrigin ],
|
||||
[ 'warSecret', this.warSecret ],
|
||||
],
|
||||
scriptletGlobals: {
|
||||
warOrigin: this.warOrigin,
|
||||
warSecret: this.warSecret,
|
||||
},
|
||||
debug: this.isDevBuild,
|
||||
debugScriptlets: µb.hiddenSettings.debugScriptlets,
|
||||
};
|
||||
if ( logger.enabled ) {
|
||||
options.scriptletGlobals.bcSecret = bcSecret;
|
||||
}
|
||||
|
||||
scriptletDetails = super.retrieve(request, options);
|
||||
|
||||
this.scriptletCache.add(hostname, scriptletDetails || null);
|
||||
if ( scriptletDetails === undefined ) {
|
||||
if ( request.nocache !== true ) {
|
||||
this.scriptletCache.add(hostname, null);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
return scriptletDetails;
|
||||
const contentScript = [];
|
||||
if ( scriptletDetails.mainWorld !== '' ) {
|
||||
contentScript.push(mainWorldInjector.assemble(hostname, scriptletDetails));
|
||||
}
|
||||
if ( scriptletDetails.isolatedWorld !== '' ) {
|
||||
contentScript.push(isolatedWorldInjector.assemble(hostname, scriptletDetails));
|
||||
}
|
||||
|
||||
const cachedScriptletDetails = {
|
||||
bcSecret,
|
||||
code: contentScript.join('\n\n'),
|
||||
filters: scriptletDetails.filters,
|
||||
};
|
||||
|
||||
if ( request.nocache !== true ) {
|
||||
this.scriptletCache.add(hostname, cachedScriptletDetails);
|
||||
}
|
||||
|
||||
return cachedScriptletDetails;
|
||||
}
|
||||
|
||||
injectNow(details) {
|
||||
if ( typeof details.frameId !== 'number' ) { return; }
|
||||
|
||||
const hostname = hostnameFromURI(details.url);
|
||||
|
||||
const request = {
|
||||
tabId: details.tabId,
|
||||
frameId: details.frameId,
|
||||
url: details.url,
|
||||
hostname: hostnameFromURI(details.url),
|
||||
domain: undefined,
|
||||
entity: undefined
|
||||
hostname,
|
||||
domain: domainFromHostname(hostname),
|
||||
entity: entityFromDomain(hostname),
|
||||
};
|
||||
|
||||
request.domain = domainFromHostname(request.hostname);
|
||||
request.entity = entityFromDomain(request.domain);
|
||||
|
||||
const scriptletDetails = this.retrieve(request);
|
||||
if ( scriptletDetails === undefined ) {
|
||||
contentScriptRegisterer.unregister(request.hostname);
|
||||
contentScriptRegisterer.unregister(hostname);
|
||||
return;
|
||||
}
|
||||
|
||||
const contentScript = [];
|
||||
const contentScript = [ scriptletDetails.code ];
|
||||
if ( logger.enabled ) {
|
||||
contentScript.unshift(
|
||||
onScriptletMessageInjector.assemble(scriptletDetails)
|
||||
);
|
||||
}
|
||||
if ( µb.hiddenSettings.debugScriptletInjector ) {
|
||||
contentScript.push('debugger');
|
||||
contentScript.unshift('debugger');
|
||||
}
|
||||
const { mainWorld = '', isolatedWorld = '', filters } = scriptletDetails;
|
||||
if ( mainWorld !== '' ) {
|
||||
contentScript.push(mainWorldInjector.assemble(request.hostname, mainWorld, filters));
|
||||
}
|
||||
if ( isolatedWorld !== '' ) {
|
||||
contentScript.push(isolatedWorldInjector.assemble(request.hostname, isolatedWorld));
|
||||
}
|
||||
|
||||
const code = contentScript.join('\n\n');
|
||||
|
||||
const isAlreadyInjected = contentScriptRegisterer.register(request.hostname, code);
|
||||
const isAlreadyInjected = contentScriptRegisterer.register(hostname, code);
|
||||
if ( isAlreadyInjected !== true ) {
|
||||
vAPI.tabs.executeScript(details.tabId, {
|
||||
code,
|
||||
|
@ -303,7 +361,6 @@ export class ScriptletFilteringEngineEx extends ScriptletFilteringEngine {
|
|||
runAt: 'document_start',
|
||||
});
|
||||
}
|
||||
|
||||
return scriptletDetails;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
/*******************************************************************************
|
||||
|
||||
uBlock Origin - a comprehensive, efficient content blocker
|
||||
Copyright (C) 2024-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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see {http://www.gnu.org/licenses/}.
|
||||
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
(( ) => {
|
||||
if ( typeof vAPI !== 'object' || vAPI === null ) { return; }
|
||||
if ( vAPI.bcSecret instanceof self.BroadcastChannel === false ) { return; }
|
||||
vAPI.bcSecret.postMessage({ what: 'setScriptletLogLevel', level: 1 });
|
||||
})();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
|
||||
DO NOT:
|
||||
- Remove the following code
|
||||
- Add code beyond the following code
|
||||
Reason:
|
||||
- https://github.com/gorhill/uBlock/pull/3721
|
||||
- uBO never uses the return value from injected content scripts
|
||||
|
||||
**/
|
||||
|
||||
void 0;
|
|
@ -0,0 +1,50 @@
|
|||
/*******************************************************************************
|
||||
|
||||
uBlock Origin - a comprehensive, efficient content blocker
|
||||
Copyright (C) 2024-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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see {http://www.gnu.org/licenses/}.
|
||||
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
(( ) => {
|
||||
if ( typeof vAPI !== 'object' || vAPI === null ) { return; }
|
||||
if ( vAPI.bcSecret instanceof self.BroadcastChannel === false ) { return; }
|
||||
vAPI.bcSecret.postMessage({ what: 'setScriptletLogLevel', level: 2 });
|
||||
})();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
|
||||
DO NOT:
|
||||
- Remove the following code
|
||||
- Add code beyond the following code
|
||||
Reason:
|
||||
- https://github.com/gorhill/uBlock/pull/3721
|
||||
- uBO never uses the return value from injected content scripts
|
||||
|
||||
**/
|
||||
|
||||
void 0;
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
(( ) => {
|
||||
try {
|
||||
let status = vAPI.uBO !== true;
|
||||
const status = vAPI.uBO !== true;
|
||||
if ( status === false && vAPI.bootstrap ) {
|
||||
self.requestIdleCallback(( ) => vAPI && vAPI.bootstrap());
|
||||
}
|
||||
|
|
|
@ -850,7 +850,8 @@ onBroadcast(msg => {
|
|||
let t0 = 0;
|
||||
|
||||
const onDone = ( ) => {
|
||||
ubolog(`loadFilterLists() took ${Date.now()-t0} ms`);
|
||||
const td = Date.now() - t0;
|
||||
ubolog(`loadFilterLists() took ${td} ms`);
|
||||
|
||||
staticNetFilteringEngine.freeze();
|
||||
staticExtFilteringEngine.freeze();
|
||||
|
@ -863,7 +864,7 @@ onBroadcast(msg => {
|
|||
logger.writeOne({
|
||||
realm: 'message',
|
||||
type: 'info',
|
||||
text: 'Reloading all filter lists: done'
|
||||
text: `Reloading all filter lists: done, took ${td} ms`
|
||||
});
|
||||
|
||||
broadcast({
|
||||
|
|
|
@ -74,10 +74,18 @@
|
|||
</span>
|
||||
</div>
|
||||
<div id="filterExprCnameOf" style="display:none"><span data-filtex="!" data-i18n="loggerRowFiltererBuiltinNot"></span><span data-filtex="\x1FaliasURL=.">CNAME</span></div>
|
||||
<div><span data-filtex="!" data-i18n="loggerRowFiltererBuiltinNot"></span>
|
||||
<span style="flex-direction: column;">
|
||||
<div><span data-filtex="\x1Finfo\x1F">info</span><span data-filtex="\x1Ferror\x1F">error</span></div>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
<button id="logLevel" class="iconified notext" data-i18n-title="loggerLogLevelTip" type="button"><span class="fa-icon">volume-up</span><span class="hover"></span></button>
|
||||
</div>
|
||||
<div>
|
||||
<button id="loggerStats" class="iconified notext" style="display: none;"><span class="fa-icon">bar-chart</span><span class="hover"></span></button>
|
||||
<button id="loggerExport" class="iconified notext"><span class="fa-icon">clipboard</span><span class="hover"></span></button>
|
||||
|
@ -92,7 +100,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div id="vwLineSizer">
|
||||
<div class="logEntry oneLine"><div><span>00:00:00</span><span> </span><span>**</span><span> </span><span>3,3</span><span>options</span><span>inline-script</span><span> </span></div></div>
|
||||
<div class="logEntry oneLine"><div class="fields"><span>00:00:00</span><span> </span><span>**</span><span> </span><span>3,3</span><span>options</span><span>inline-script</span><span> </span></div></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -109,7 +117,7 @@
|
|||
</div>
|
||||
|
||||
<div id="templates" style="display: none;">
|
||||
<div id="logEntryTemplate"><div><span></span>​<span></span>​<span></span>​<span></span>​<span></span>​<span></span>​<span></span>​<span></span></div></div>
|
||||
<div id="logEntryTemplate"><div class="fields"><span></span>​<span></span>​<span></span>​<span></span>​<span></span>​<span></span>​<span></span>​<span></span></div></div>
|
||||
|
||||
<div class="netFilteringDialog" data-pane="details">
|
||||
<div class="dialogControls">
|
||||
|
|
Loading…
Reference in New Issue