|
407 | 407 | needle = new RegExp(needle);
|
408 | 408 | window.requestAnimationFrame = new Proxy(window.requestAnimationFrame, {
|
409 | 409 | apply: function(target, thisArg, args) {
|
410 |
| - const a = args[0]; |
411 |
| - const s = a.toString(); |
| 410 | + const a = String(args[0]); |
412 | 411 | if ( log !== undefined ) {
|
413 |
| - log('uBO: requestAnimationFrame("%s")', s); |
414 |
| - } |
415 |
| - if ( needle.test(s) === not ) { |
| 412 | + log('uBO: requestAnimationFrame("%s")', a); |
| 413 | + } else if ( needle.test(a) === not ) { |
416 | 414 | args[0] = function(){};
|
417 | 415 | }
|
418 | 416 | return target.apply(thisArg, args);
|
|
528 | 526 | })();
|
529 | 527 |
|
530 | 528 |
|
531 |
| -/// setInterval-logger.js |
532 |
| -/// alias sil.js |
| 529 | +/// setInterval-if.js |
| 530 | +/// alias siif.js |
533 | 531 | (function() {
|
534 |
| - const log = console.log.bind(console); |
| 532 | + let needle = '{{1}}'; |
| 533 | + const not = needle.charAt(0) === '!'; |
| 534 | + if ( not ) { needle = needle.slice(1); } |
| 535 | + const delay = parseInt('{{2}}', 10); |
| 536 | + if ( needle === '' || needle === '{{1}}' ) { |
| 537 | + needle = '.?'; |
| 538 | + } else if ( needle.startsWith('/') && needle.endsWith('/') ) { |
| 539 | + needle = needle.slice(1,-1); |
| 540 | + } else { |
| 541 | + needle = needle.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); |
| 542 | + } |
| 543 | + const log = not === false && needle === '.?' && isNaN(delay) |
| 544 | + ? console.log |
| 545 | + : undefined; |
| 546 | + needle = new RegExp(needle); |
535 | 547 | window.setInterval = new Proxy(window.setInterval, {
|
536 | 548 | apply: function(target, thisArg, args) {
|
537 |
| - const a = args[0]; |
| 549 | + const a = String(args[0]); |
538 | 550 | const b = args[1];
|
539 |
| - log('uBO: setInterval("%s", %s)', a.toString(), b); |
| 551 | + if ( log !== undefined ) { |
| 552 | + log('uBO: setInterval("%s", %s)', a, b); |
| 553 | + } else if ( |
| 554 | + (isNaN(delay) || b === delay) && |
| 555 | + needle.test(a) === not |
| 556 | + ) { |
| 557 | + args[0] = function(){}; |
| 558 | + } |
540 | 559 | return target.apply(thisArg, args);
|
541 | 560 | }
|
542 | 561 | });
|
|
569 | 588 | })();
|
570 | 589 |
|
571 | 590 |
|
572 |
| -/// setTimeout-logger.js |
573 |
| -/// alias stl.js |
| 591 | +/// setTimeout-if.js |
| 592 | +/// alias stif.js |
574 | 593 | (function() {
|
575 |
| - const log = console.log.bind(console); |
| 594 | + let needle = '{{1}}'; |
| 595 | + const not = needle.charAt(0) === '!'; |
| 596 | + if ( not ) { needle = needle.slice(1); } |
| 597 | + const delay = parseInt('{{2}}', 10); |
| 598 | + if ( needle === '' || needle === '{{1}}' ) { |
| 599 | + needle = '.?'; |
| 600 | + } else if ( needle.startsWith('/') && needle.endsWith('/') ) { |
| 601 | + needle = needle.slice(1,-1); |
| 602 | + } else { |
| 603 | + needle = needle.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); |
| 604 | + } |
| 605 | + const log = not === false && needle === '.?' && isNaN(delay) |
| 606 | + ? console.log |
| 607 | + : undefined; |
| 608 | + needle = new RegExp(needle); |
576 | 609 | window.setTimeout = new Proxy(window.setTimeout, {
|
577 | 610 | apply: function(target, thisArg, args) {
|
578 |
| - const a = args[0]; |
| 611 | + const a = String(args[0]); |
579 | 612 | const b = args[1];
|
580 |
| - log('uBO: setTimeout("%s", %s)', a.toString(), b); |
| 613 | + if ( log !== undefined ) { |
| 614 | + log('uBO: setTimeout("%s", %s)', a, b); |
| 615 | + } else if ( |
| 616 | + (isNaN(delay) || b === delay) && |
| 617 | + needle.test(a) === not |
| 618 | + ) { |
| 619 | + args[0] = function(){}; |
| 620 | + } |
581 | 621 | return target.apply(thisArg, args);
|
582 | 622 | }
|
583 | 623 | });
|
|
0 commit comments