|
32 | 32 |
|
33 | 33 |
|
34 | 34 |
|
35 |
| -/// abort-current-inline-script.js |
| 35 | +/// abort-current-script.js |
| 36 | +/// alias acs.js |
| 37 | +/// alias abort-current-inline-script.js |
36 | 38 | /// alias acis.js
|
37 | 39 | (function() {
|
38 | 40 | const target = '{{1}}';
|
39 | 41 | if ( target === '' || target === '{{1}}' ) { return; }
|
| 42 | + const reRegexEscape = /[.*+?^${}()|[\]\\]/g; |
40 | 43 | const needle = '{{2}}';
|
41 |
| - let reText = '.?'; |
42 |
| - if ( needle !== '' && needle !== '{{2}}' ) { |
43 |
| - reText = /^\/.+\/$/.test(needle) |
44 |
| - ? needle.slice(1,-1) |
45 |
| - : needle.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); |
46 |
| - } |
| 44 | + const reText = (( ) => { |
| 45 | + if ( needle === '' || needle === '{{2}}' ) { return /^/; } |
| 46 | + if ( /^\/.+\/$/.test(needle) ) { |
| 47 | + return new RegExp(needle.slice(1,-1)); |
| 48 | + } |
| 49 | + return new RegExp(needle.replace(reRegexEscape, '\\$&')); |
| 50 | + })(); |
| 51 | + const context = '{{3}}'; |
| 52 | + const reContext = (( ) => { |
| 53 | + if ( context === '' || context === '{{3}}' ) { return /^$/; } |
| 54 | + if ( /^\/.+\/$/.test(context) ) { |
| 55 | + return new RegExp(context.slice(1,-1)); |
| 56 | + } |
| 57 | + return new RegExp(context.replace(reRegexEscape, '\\$&')); |
| 58 | + })(); |
47 | 59 | const thisScript = document.currentScript;
|
48 | 60 | const re = new RegExp(reText);
|
49 | 61 | const chain = target.split('.');
|
|
70 | 82 | const e = document.currentScript;
|
71 | 83 | if (
|
72 | 84 | e instanceof HTMLScriptElement &&
|
73 |
| - e.src === '' && |
| 85 | + reContext.test(e.src) && |
74 | 86 | e !== thisScript &&
|
75 | 87 | re.test(e.textContent)
|
76 | 88 | ) {
|
|
0 commit comments