├── term.bat ├── src ├── war │ ├── nano-tiny-noopvast-2.xml │ └── nano-tiny-noopvast-3.xml ├── img │ ├── cloud.png │ ├── 128_off.png │ ├── 128_on.png │ └── help16.png ├── icons │ ├── icon_150.png │ ├── icon_16.png │ ├── icon_256.png │ ├── icon_44.png │ └── icon_50.png ├── fonts │ └── fontawesome-webfont.ttf ├── js │ ├── nano-platform-vars.js │ ├── nano-vapi.js │ ├── nano-asset-viewer.js │ └── nano-1p-filters.js └── _locales │ ├── zh_CN │ └── messages.json │ ├── zh_TW │ └── messages.json │ ├── ja │ └── messages.json │ └── en │ └── messages.json ├── renovate.json ├── .gitattributes ├── .gitignore ├── patches ├── 00_0_textarea_spacing.patch ├── integration │ ├── 22_1_font_awesome.patch │ ├── 20_0_force_scroll_background.patch │ ├── 10_5_linters.patch │ ├── 00_2_vapi_icon.patch │ ├── 20_1_bug_reporter_background.patch │ ├── 10_4_extended_options.patch │ ├── 10_0_load_scripts.patch │ ├── 10_2_extended_resources.patch │ ├── 00_1_version_parsing.patch │ ├── 21_2_bug_reporter.patch │ ├── 30_1_editor_settings.patch │ ├── 10_7_filter_editor.patch │ ├── 10_8_filter_viewer.patch │ ├── README.MD │ ├── 22_3_new_bug_reporter.patch │ ├── 10_3_force_recompile.patch │ ├── 21_1_force_scroll.patch │ ├── 22_2_new_force_scroll.patch │ ├── 22_0_new_popup_tweaks.patch │ ├── 00_3_favicon.patch │ ├── 00_0_about.patch │ ├── 30_2_link_differences.patch │ ├── 90_0_settings_migration.patch │ ├── 10_1_compile_flags.patch │ ├── 21_0_popup_tweaks.patch │ └── 30_0_settings_tweaks.patch ├── 90_0_assets_migration.patch ├── 20_3_reset_hard.patch ├── 20_4_log_script_snippet_errors.patch ├── 20_2_hard_purge_any_key.patch ├── 30_0_link_resources.patch ├── 10_0_user_css.patch ├── 20_6_autocomment_href.patch ├── 20_1_header_parsing.patch ├── 20_5_other_editors_style.patch ├── README.MD ├── 90_1_cherry_pick_fixes.patch └── 20_0_configuration_tweaks.patch ├── notes ├── dashboard_whitelist.md ├── dashboard_my_rules.md ├── privacy_policy.md ├── filter_syntax.md ├── developer_notes.md ├── advanced_settings.md └── sanity_tests.md ├── description └── en │ └── webstore.txt ├── term ├── package.json ├── syntax.js ├── term.js ├── data.js ├── store.js └── crowdin.js ├── config.nano.js └── README.MD /term.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | NODE ./term 4 | 5 | PAUSE 6 | -------------------------------------------------------------------------------- /src/war/nano-tiny-noopvast-2.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/war/nano-tiny-noopvast-3.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "hugoxu" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Make sure patch files have corrent line ending 2 | *.patch text eol=lf 3 | -------------------------------------------------------------------------------- /src/img/cloud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanoAdblocker/NanoCore2/HEAD/src/img/cloud.png -------------------------------------------------------------------------------- /src/img/128_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanoAdblocker/NanoCore2/HEAD/src/img/128_off.png -------------------------------------------------------------------------------- /src/img/128_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanoAdblocker/NanoCore2/HEAD/src/img/128_on.png -------------------------------------------------------------------------------- /src/img/help16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanoAdblocker/NanoCore2/HEAD/src/img/help16.png -------------------------------------------------------------------------------- /src/icons/icon_150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanoAdblocker/NanoCore2/HEAD/src/icons/icon_150.png -------------------------------------------------------------------------------- /src/icons/icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanoAdblocker/NanoCore2/HEAD/src/icons/icon_16.png -------------------------------------------------------------------------------- /src/icons/icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanoAdblocker/NanoCore2/HEAD/src/icons/icon_256.png -------------------------------------------------------------------------------- /src/icons/icon_44.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanoAdblocker/NanoCore2/HEAD/src/icons/icon_44.png -------------------------------------------------------------------------------- /src/icons/icon_50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanoAdblocker/NanoCore2/HEAD/src/icons/icon_50.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Node modules 2 | node_modules/ 3 | 4 | # Workspace 5 | temp/ 6 | 7 | # Build results 8 | build/ 9 | -------------------------------------------------------------------------------- /src/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanoAdblocker/NanoCore2/HEAD/src/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /patches/00_0_textarea_spacing.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/css/common.css b/src/css/common.css 2 | index f1c26292..ea21abd3 100644 3 | --- a/src/css/common.css 4 | +++ b/src/css/common.css 5 | @@ -84,6 +84,7 @@ hr { 6 | } 7 | textarea { 8 | font-size: 90%; 9 | + font-family: monospace; 10 | } 11 | button { 12 | align-items: center; 13 | -------------------------------------------------------------------------------- /patches/integration/22_1_font_awesome.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/css/popup-fenix.css b/src/css/popup-fenix.css 2 | index 3f99c13f..86fea2a3 100644 3 | --- a/src/css/popup-fenix.css 4 | +++ b/src/css/popup-fenix.css 5 | @@ -3,6 +3,10 @@ 6 | bottom: auto; 7 | top: -20%; 8 | } 9 | +.fa.tool { 10 | + font-weight: bold; 11 | + text-align: center; 12 | + } 13 | 14 | /* Internal CSS values */ 15 | :root body { 16 | -------------------------------------------------------------------------------- /notes/dashboard_whitelist.md: -------------------------------------------------------------------------------- 1 | # Dashboard - Whitelist 2 | 3 | If you are not familiar with whitelists in uBlock Origin, 4 | [**please read this first**](https://github.com/gorhill/uBlock/wiki/Dashboard:-Whitelist). 5 | 6 | ## Differences 7 | 8 | Nano Adblocker has a slightly different default whitelists: 9 | 10 | ``` 11 | about-scheme 12 | chrome-extension-scheme 13 | chrome-scheme 14 | edge-extension-scheme 15 | edge-scheme 16 | moz-extension-scheme 17 | ms-browser-extension-scheme 18 | opera-scheme 19 | vivaldi-scheme 20 | wyciwyg-scheme 21 | ``` 22 | -------------------------------------------------------------------------------- /patches/90_0_assets_migration.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/js/redirect-engine.js b/src/js/redirect-engine.js 2 | index 5e009197..f2f67e83 100644 3 | --- a/src/js/redirect-engine.js 4 | +++ b/src/js/redirect-engine.js 5 | @@ -731,6 +731,7 @@ const removeTopCommentBlock = function(text) { 6 | RedirectEngine.prototype.loadBuiltinResources = function() { 7 | // TODO: remove once usage of uBO 1.20.4 is widespread. 8 | µBlock.assets.remove('ublock-resources'); 9 | + µBlock.assets.remove('nano-resources'); 10 | 11 | this.resources = new Map(); 12 | this.aliases = new Map(); 13 | -------------------------------------------------------------------------------- /description/en/webstore.txt: -------------------------------------------------------------------------------- 1 | Features highlight 2 | - Block ads and popups, works out of the box 3 | - Create elements hiding rules through extension icon 4 | - Report an issue or bug with a few clicks 5 | - Powerful filters editor and linter for advanced users and filters maintainers 6 | 7 | Best experience with Nano Defender. 8 | 9 | Home page: https://github.com/NanoAdblocker/NanoCore 10 | 11 | Source code: https://github.com/NanoAdblocker/NanoCore2 12 | 13 | Report issues: https://github.com/NanoAdblocker/NanoCore/issues 14 | 15 | Based on uBlock Origin: https://github.com/gorhill/uBlock 16 | -------------------------------------------------------------------------------- /patches/integration/20_0_force_scroll_background.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/js/messaging.js b/src/js/messaging.js 2 | index 200c3f6f..8ecefeb0 100644 3 | --- a/src/js/messaging.js 4 | +++ b/src/js/messaging.js 5 | @@ -137,6 +137,10 @@ const onMessage = function(request, sender, callback) { 6 | µb.elementPickerExec(request.tabId, request.targetURL, request.zap); 7 | break; 8 | 9 | + case 'nanoInjectForceScrollCSS': 10 | + nano.inject_force_scroll(request.tabId); 11 | + break; 12 | + 13 | case 'gotoURL': 14 | µb.openNewTab(request.details); 15 | break; 16 | -------------------------------------------------------------------------------- /patches/integration/10_5_linters.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/js/messaging.js b/src/js/messaging.js 2 | index de13e620..200c3f6f 100644 3 | --- a/src/js/messaging.js 4 | +++ b/src/js/messaging.js 5 | @@ -1192,6 +1192,13 @@ const onMessage = function(request, sender, callback) { 6 | nano.recompile_filters(); 7 | break; 8 | 9 | + case 'nanoGetFilterLinterResult': 10 | + response = { 11 | + errors: nano.fl.errors, 12 | + warnings: nano.fl.warnings 13 | + }; 14 | + break; 15 | + 16 | default: 17 | return vAPI.messaging.UNHANDLED; 18 | } 19 | -------------------------------------------------------------------------------- /term/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "jspenguin2017", 3 | "bugs": { 4 | "url": "https://github.com/NanoAdblocker/NanoCore/issues" 5 | }, 6 | "dependencies": { 7 | "archiver": "5.0.2", 8 | "esprima": "4.0.1", 9 | "fs-extra": "9.0.1", 10 | "yauzl": "2.10.0" 11 | }, 12 | "description": "Nano Core 2 Terminal", 13 | "engines": { 14 | "node": "12.19.0" 15 | }, 16 | "homepage": "https://github.com/jspenguin2017/NanoCore2", 17 | "license": "GPL-3.0", 18 | "name": "nano-core-2-term", 19 | "private": true, 20 | "repository": "https://github.com/jspenguin2017/NanoCore2", 21 | "version": "1.0.26" 22 | } 23 | -------------------------------------------------------------------------------- /patches/20_3_reset_hard.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/js/messaging.js b/src/js/messaging.js 2 | index 8ecefeb0..77ae124b 100644 3 | --- a/src/js/messaging.js 4 | +++ b/src/js/messaging.js 5 | @@ -953,16 +953,12 @@ const restoreUserData = async function(request) { 6 | vAPI.app.restart(); 7 | }; 8 | 9 | -// Remove all stored data but keep global counts, people can become 10 | -// quite attached to numbers 11 | const resetUserData = async function() { 12 | await Promise.all([ 13 | µb.cacheStorage.clear(), 14 | vAPI.storage.clear(), 15 | ]); 16 | 17 | - await µb.saveLocalSettings(); 18 | - 19 | vAPI.app.restart(); 20 | }; 21 | 22 | -------------------------------------------------------------------------------- /notes/dashboard_my_rules.md: -------------------------------------------------------------------------------- 1 | # Dashboard - My Rules 2 | 3 | If you are not familiar with dynamic filtering rules in uBlock Origin, 4 | [**please read this first**](https://github.com/gorhill/uBlock/wiki/Dynamic-filtering:-rule-syntax). 5 | 6 | ## Differences 7 | 8 | Nano Adblocker has a slightly different default dynamic filtering rules: 9 | 10 | ``` 11 | no-csp-reports: * true 12 | no-large-media: behind-the-scene false 13 | behind-the-scene * * noop 14 | behind-the-scene * 1p-script noop 15 | behind-the-scene * 3p noop 16 | behind-the-scene * 3p-frame noop 17 | behind-the-scene * 3p-script noop 18 | behind-the-scene * image noop 19 | behind-the-scene * inline-script noop 20 | ``` 21 | -------------------------------------------------------------------------------- /patches/20_4_log_script_snippet_errors.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/js/scriptlet-filtering.js b/src/js/scriptlet-filtering.js 2 | index eab9ff9b..87e54fa7 100644 3 | --- a/src/js/scriptlet-filtering.js 4 | +++ b/src/js/scriptlet-filtering.js 5 | @@ -230,7 +230,9 @@ 6 | content = 7 | 'try {\n' + 8 | content.replace('{{nano}}', '') + '\n' + 9 | - '} catch ( e ) { }'; 10 | + '} catch ( e ) {\n' + 11 | + ' console.error("[Nano] Script Snippet ::", e);\n' + 12 | + '}'; 13 | scriptletCache.add(rawToken, content); 14 | } 15 | toInject.set(rawToken, content); 16 | -------------------------------------------------------------------------------- /patches/integration/00_2_vapi_icon.patch: -------------------------------------------------------------------------------- 1 | diff --git a/platform/chromium/vapi-background.js b/platform/chromium/vapi-background.js 2 | index 03737aab..ad7813dd 100644 3 | --- a/platform/chromium/vapi-background.js 4 | +++ b/platform/chromium/vapi-background.js 5 | @@ -704,8 +704,8 @@ vAPI.setIcon = (( ) => { 6 | browser.runtime.getManifest().browser_action.default_title + 7 | ' ({badge})'; 8 | const icons = [ 9 | - { path: { '16': 'img/icon_16-off.png', '32': 'img/icon_32-off.png' } }, 10 | - { path: { '16': 'img/icon_16.png', '32': 'img/icon_32.png' } }, 11 | + { path: { '128': 'img/128_off.png' } }, 12 | + { path: { '128': 'img/128_on.png' } }, 13 | ]; 14 | 15 | (( ) => { 16 | -------------------------------------------------------------------------------- /patches/20_2_hard_purge_any_key.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/js/3p-filters.js b/src/js/3p-filters.js 2 | index 99bbe9b6..8c315959 100644 3 | --- a/src/js/3p-filters.js 4 | +++ b/src/js/3p-filters.js 5 | @@ -678,7 +678,7 @@ uDom('#ignoreGenericCosmeticFilters').on('change', onFilteringSettingsChanged); 6 | uDom('#buttonApply').on('click', ( ) => { buttonApplyHandler(); }); 7 | uDom('#buttonUpdate').on('click', ( ) => { buttonUpdateHandler(); }); 8 | uDom('#buttonPurgeAll').on('click', ev => { 9 | - buttonPurgeAllHandler(ev.ctrlKey && ev.shiftKey); 10 | + buttonPurgeAllHandler(ev.ctrlKey || ev.metaKey || ev.shiftKey); 11 | }); 12 | uDom('#lists').on('change', '.listEntry input', onListsetChanged); 13 | uDom('#lists').on('click', '.listEntry .remove', onRemoveExternalList); 14 | -------------------------------------------------------------------------------- /patches/integration/20_1_bug_reporter_background.patch: -------------------------------------------------------------------------------- 1 | diff --git a/platform/chromium/vapi-common.js b/platform/chromium/vapi-common.js 2 | index 38076516..80b69fe8 100644 3 | --- a/platform/chromium/vapi-common.js 4 | +++ b/platform/chromium/vapi-common.js 5 | @@ -177,6 +177,16 @@ vAPI.download = function(details) { 6 | 7 | vAPI.getURL = browser.runtime.getURL; 8 | 9 | +vAPI.nanoOpenBugReporter = function(tabId) { 10 | + const reporter = vAPI.getURL('/reporter/index.html'); 11 | + 12 | + if ( typeof tabId === "number" ) { 13 | + chrome.tabs.create({ 14 | + url: reporter + '?' + tabId 15 | + }); 16 | + } 17 | +}; 18 | + 19 | /******************************************************************************/ 20 | 21 | vAPI.i18n = browser.i18n.getMessage; 22 | -------------------------------------------------------------------------------- /patches/30_0_link_resources.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/1p-filters.html b/src/1p-filters.html 2 | index 10dddd2a..8b24b75d 100644 3 | --- a/src/1p-filters.html 4 | +++ b/src/1p-filters.html 5 | @@ -19,6 +19,7 @@ 6 |
7 | 8 |

9 | +

10 |

11 | 12 | 13 | -------------------------------------------------------------------------------- /patches/integration/10_4_extended_options.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/js/redirect-engine.js b/src/js/redirect-engine.js 2 | index fca01197..ea5b1cb8 100644 3 | --- a/src/js/redirect-engine.js 4 | +++ b/src/js/redirect-engine.js 5 | @@ -546,6 +546,8 @@ RedirectEngine.prototype.supportedTypes = new Map([ 6 | [ 'subdocument', 'sub_frame' ], 7 | [ 'xhr', 'xmlhttprequest' ], 8 | [ 'xmlhttprequest', 'xmlhttprequest' ], 9 | + 10 | + [ 'iframe', 'sub_frame' ], 11 | ]); 12 | 13 | /******************************************************************************/ 14 | diff --git a/src/js/static-net-filtering.js b/src/js/static-net-filtering.js 15 | index b88e4974..c08ed70c 100644 16 | --- a/src/js/static-net-filtering.js 17 | +++ b/src/js/static-net-filtering.js 18 | @@ -161,6 +161,8 @@ const toNormalizedType = { 19 | 'xmlhttprequest': 'xmlhttprequest', 20 | 'webrtc': 'unsupported', 21 | 'websocket': 'websocket', 22 | + 23 | + 'iframe': 'subdocument', 24 | }; 25 | 26 | const typeValueFromCatBits = catBits => (catBits >>> 4) & 0b11111; 27 | -------------------------------------------------------------------------------- /patches/10_0_user_css.patch: -------------------------------------------------------------------------------- 1 | diff --git a/platform/chromium/vapi-common.js b/platform/chromium/vapi-common.js 2 | index 80b69fe8..2820413b 100644 3 | --- a/platform/chromium/vapi-common.js 4 | +++ b/platform/chromium/vapi-common.js 5 | @@ -100,11 +100,6 @@ vAPI.webextFlavor = { 6 | soup.add('apple').add('safari'); 7 | } 8 | 9 | - // https://github.com/gorhill/uBlock/issues/3588 10 | - if ( soup.has('chromium') && flavor.major >= 66 ) { 11 | - soup.add('user_stylesheet'); 12 | - } 13 | - 14 | // Don't starve potential listeners 15 | vAPI.setTimeout(dispatch, 97); 16 | })(); 17 | diff --git a/platform/chromium/vapi-usercss.js b/platform/chromium/vapi-usercss.js 18 | index 0cf97b7a..cebc2d1d 100644 19 | --- a/platform/chromium/vapi-usercss.js 20 | +++ b/platform/chromium/vapi-usercss.js 21 | @@ -29,8 +29,7 @@ 22 | // https://github.com/gorhill/uBlock/issues/3588 23 | 24 | if ( typeof vAPI === 'object' ) { 25 | - vAPI.supportsUserStylesheets = 26 | - /\bChrom(?:e|ium)\/(?:5\d|6[012345])\b/.test(navigator.userAgent) === false; 27 | + vAPI.supportsUserStylesheets = false; 28 | } 29 | 30 | 31 | -------------------------------------------------------------------------------- /patches/20_6_autocomment_href.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/js/scriptlets/element-picker.js b/src/js/scriptlets/element-picker.js 2 | index 53fd61e2..ecd4c501 100644 3 | --- a/src/js/scriptlets/element-picker.js 4 | +++ b/src/js/scriptlets/element-picker.js 5 | @@ -1095,6 +1095,7 @@ const onDialogClicked = function(ev) { 6 | what: 'createUserFilter', 7 | autoComment: true, 8 | filters: filter, 9 | + nanoHref: window.location.href, 10 | origin: window.location.origin, 11 | pageDomain: window.location.hostname, 12 | killCache: isCosmetic === false, 13 | diff --git a/src/js/storage.js b/src/js/storage.js 14 | index 272127b0..96ce8692 100644 15 | --- a/src/js/storage.js 16 | +++ b/src/js/storage.js 17 | @@ -396,7 +396,8 @@ self.addEventListener('hiddenSettingsChanged', ( ) => { 18 | this.hiddenSettings.autoCommentFilterTemplate 19 | .replace('{{date}}', d.toLocaleDateString()) 20 | .replace('{{time}}', d.toLocaleTimeString()) 21 | - .replace('{{origin}}', options.origin); 22 | + .replace('{{origin}}', options.origin) 23 | + .replace('{{nanoHref}}', options.nanoHref); 24 | } 25 | 26 | const details = await this.loadUserFilters(); 27 | -------------------------------------------------------------------------------- /patches/integration/10_0_load_scripts.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/background.html b/src/background.html 2 | index 8db73659..010fc82f 100644 3 | --- a/src/background.html 4 | +++ b/src/background.html 5 | @@ -9,12 +9,15 @@ 6 | 7 | 8 | 9 | + 10 | 11 | 12 | 13 | 14 | 15 | + 16 | 17 | + 18 | 19 | 20 | 21 | diff --git a/src/js/background.js b/src/js/background.js 22 | index 433ecedf..98278f21 100644 23 | --- a/src/js/background.js 24 | +++ b/src/js/background.js 25 | @@ -208,3 +208,7 @@ const µBlock = (( ) => { // jshint ignore:line 26 | })(); 27 | 28 | /******************************************************************************/ 29 | + 30 | +window.__ublock__ = µBlock; 31 | + 32 | +/******************************************************************************/ 33 | -------------------------------------------------------------------------------- /patches/20_1_header_parsing.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/js/storage.js b/src/js/storage.js 2 | index 04bae91b..272127b0 100644 3 | --- a/src/js/storage.js 4 | +++ b/src/js/storage.js 5 | @@ -764,15 +764,33 @@ self.addEventListener('hiddenSettingsChanged', ( ) => { 6 | } 7 | // Extract update frequency information 8 | const matches = head.match(/(?:^|\n)(?:!|# )[\t ]*Expires[\t ]*:[\t ]*(\d+)[\t ]*(h)?/i); 9 | + let v; 10 | if ( matches !== null ) { 11 | - let v = Math.max(parseInt(matches[1], 10), 1); 12 | + v = parseInt(matches[1], 10); 13 | if ( matches[2] !== undefined ) { 14 | v = Math.ceil(v / 24); 15 | } 16 | - if ( v !== listEntry.updateAfter ) { 17 | - this.assets.registerAssetSource(assetKey, { updateAfter: v }); 18 | + } 19 | + 20 | + if ( typeof v !== 'number' ) { 21 | + if ( typeof listEntry.nanoUpdateAfterDefault === 'number' ) { 22 | + v = listEntry.nanoUpdateAfterDefault; 23 | + } else { 24 | + // IMPORTANT! Must update this value if default update period is 25 | + // changed 26 | + v = 3; 27 | } 28 | } 29 | + 30 | + if ( v < 1 ) { 31 | + v = 1; 32 | + } else if ( v > 60 ) { 33 | + v = 60; 34 | + } 35 | + 36 | + if ( v !== listEntry.updateAfter ) { 37 | + this.assets.registerAssetSource(assetKey, { updateAfter: v }); 38 | + } 39 | }; 40 | 41 | /******************************************************************************/ 42 | -------------------------------------------------------------------------------- /patches/integration/10_2_extended_resources.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/js/redirect-engine.js b/src/js/redirect-engine.js 2 | index 3f607cfe..fca01197 100644 3 | --- a/src/js/redirect-engine.js 4 | +++ b/src/js/redirect-engine.js 5 | @@ -180,6 +180,9 @@ const typeToMimeMap = new Map([ 6 | [ 'xmlhttprequest', 'text/plain' ], 7 | ]); 8 | 9 | +nano.insert_redirect_declaration(redirectableResources); 10 | +nano.insert_mime_declaration(extToMimeMap); 11 | + 12 | const validMimes = new Set(extToMimeMap.values()); 13 | 14 | const mimeFromName = function(name) { 15 | diff --git a/src/js/scriptlet-filtering.js b/src/js/scriptlet-filtering.js 16 | index 9575047d..e58e0df9 100644 17 | --- a/src/js/scriptlet-filtering.js 18 | +++ b/src/js/scriptlet-filtering.js 19 | @@ -229,7 +229,7 @@ 20 | } 21 | content = 22 | 'try {\n' + 23 | - content + '\n' + 24 | + content.replace('{{nano}}', '') + '\n' + 25 | '} catch ( e ) { }'; 26 | scriptletCache.add(rawToken, content); 27 | } 28 | @@ -307,6 +307,14 @@ 29 | return; 30 | } 31 | 32 | + var nanoInjectArgs = parsed.suffix.slice(4, -1); 33 | + if ( 34 | + !nano.cf.is_privileged && 35 | + nanoInjectArgs.startsWith(nano.privileged_assets_previx) 36 | + ) { 37 | + return; 38 | + } 39 | + 40 | // https://github.com/gorhill/uBlock/issues/3375 41 | // Ignore instances of exception filter with negated hostnames, 42 | // because there is no way to create an exception to an exception. 43 | -------------------------------------------------------------------------------- /patches/integration/00_1_version_parsing.patch: -------------------------------------------------------------------------------- 1 | diff --git a/platform/chromium/vapi-background.js b/platform/chromium/vapi-background.js 2 | index fc3caa47..03737aab 100644 3 | --- a/platform/chromium/vapi-background.js 4 | +++ b/platform/chromium/vapi-background.js 5 | @@ -57,16 +57,8 @@ window.addEventListener('webextFlavor', function() { 6 | /******************************************************************************/ 7 | 8 | vAPI.app = { 9 | - name: manifest.name.replace(/ dev\w+ build/, ''), 10 | - version: (( ) => { 11 | - let version = manifest.version; 12 | - const match = /(\d+\.\d+\.\d+)(?:\.(\d+))?/.exec(version); 13 | - if ( match && match[2] ) { 14 | - const v = parseInt(match[2], 10); 15 | - version = match[1] + (v < 100 ? 'b' + v : 'rc' + (v - 100)); 16 | - } 17 | - return version; 18 | - })(), 19 | + name: manifest.name, 20 | + version: manifest.version, 21 | 22 | intFromVersion: function(s) { 23 | const parts = s.match(/(?:^|\.|b|rc)\d+/g); 24 | diff --git a/platform/chromium/vapi-common.js b/platform/chromium/vapi-common.js 25 | index 30e09c57..38076516 100644 26 | --- a/platform/chromium/vapi-common.js 27 | +++ b/platform/chromium/vapi-common.js 28 | @@ -51,11 +51,6 @@ vAPI.webextFlavor = { 29 | // This is always true. 30 | soup.add('ublock').add('webext'); 31 | 32 | - // Whether this is a dev build. 33 | - if ( /^\d+\.\d+\.\d+\D/.test(browser.runtime.getManifest().version) ) { 34 | - soup.add('devbuild'); 35 | - } 36 | - 37 | if ( /\bMobile\b/.test(ua) ) { 38 | soup.add('mobile'); 39 | } 40 | -------------------------------------------------------------------------------- /patches/integration/21_2_bug_reporter.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/js/popup.js b/src/js/popup.js 2 | index feea0361..e98927e6 100644 3 | --- a/src/js/popup.js 4 | +++ b/src/js/popup.js 5 | @@ -776,6 +776,10 @@ const nanoForceEnableScroll = function() { 6 | vAPI.closePopup(); 7 | }; 8 | 9 | +const nanoOpenBugReporter = function() { 10 | + vAPI.nanoOpenBugReporter(popupData.tabId); 11 | +}; 12 | + 13 | /******************************************************************************/ 14 | 15 | const gotoURL = function(ev) { 16 | @@ -1222,6 +1226,7 @@ uDom('#switch .fa-icon').on('click', toggleNetFilteringSwitch); 17 | uDom('#gotoZap').on('click', gotoZap); 18 | uDom('#gotoPick').on('click', gotoPick); 19 | uDom('#nanoForceEnableScroll').on('click', nanoForceEnableScroll); 20 | +uDom('#nanoOpenBugReporter').on('click', nanoOpenBugReporter); 21 | uDom('#nanoFirewallPaneToggle').on('click', toggleFirewallPane); 22 | uDom('.hnSwitch').on('click', ev => { toggleHostnameSwitch(ev); }); 23 | uDom('#saveRules').on('click', saveFirewallRules); 24 | diff --git a/src/popup.html b/src/popup.html 25 | index 9314430a..dd46b5ac 100644 26 | --- a/src/popup.html 27 | +++ b/src/popup.html 28 | @@ -25,6 +25,7 @@ 29 |

30 | bolt 31 | 32 | + 33 |

34 |

 

35 |

36 | -------------------------------------------------------------------------------- /src/js/nano-platform-vars.js: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------------------------------- // 2 | 3 | // Nano Core 2 - An adblocker 4 | // Copyright (C) 2018-2019 Nano Core 2 contributors 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | 19 | // ----------------------------------------------------------------------------------------------------------------- // 20 | 21 | // Platform constants 22 | 23 | // ----------------------------------------------------------------------------------------------------------------- // 24 | 25 | "use strict"; 26 | 27 | // ----------------------------------------------------------------------------------------------------------------- // 28 | 29 | var nano = nano || {}; 30 | 31 | // ----------------------------------------------------------------------------------------------------------------- // 32 | 33 | nano.defender_ext_id_chrome = "ggolfgbegefeeoocgjbmkembbncoadlb"; 34 | 35 | nano.defender_ext_id_edge = "ijfkmnlofajajikjhfiigelipempcklj"; 36 | 37 | // ----------------------------------------------------------------------------------------------------------------- // 38 | -------------------------------------------------------------------------------- /notes/privacy_policy.md: -------------------------------------------------------------------------------- 1 | # Privacy Policy 2 | 3 | This Privacy Policy (the "Policy") only applies to the latest unmodified 4 | production builds of Nano Adblocker and Nano Defender (the "Projects") 5 | published and distributed by `@jspenguin2017` (the "Author"). 6 | 7 | By using one or both of the Projects, you consent to: 8 | - The most recent version of the Policy 9 | 10 | ### Data Collection 11 | 12 | The Projects do not actively collect any data of any kind. 13 | 14 | ### Side Channels 15 | 16 | Nano Adblocker may connect to remote servers to download assets updates. 17 | Built-in assets are defined 18 | [here](https://github.com/NanoAdblocker/NanoCore2/blob/master/src/assets.json). 19 | You may import other assets, in which case Nano Adblocker will connect to 20 | additional servers as per your instruction. 21 | 22 | Nano Adblocker may supply a cache buster when downloading assets updates, 23 | which may reveal your system time accurate to about 1 hour. Your timezone will 24 | be kept private. You may configure Nano Adblocker to more aggressively bypass 25 | cache in advanced settings, in which case Nano Adblocker will reveal your 26 | system time accurate to about 1 second. 27 | 28 | Nano Defender may connect to third-party servers when doing so is required to 29 | fix a website, only the bare minimum data required to successfully perform the 30 | request will be sent. 31 | 32 | ### Other Features 33 | 34 | If you choose to use these features, you must consent to additional privacy 35 | policies. These features are optional and do not affect the primary 36 | functionalities of the Projects. 37 | 38 | - [Quick Issue Reporter](https://github.com/jspenguin2017/uBlockProtector/blob/master/notes/issue-reporter.md) 39 | 40 | ### Future Versions 41 | 42 | The Policy may be modified at any time, with or without notice. 43 | -------------------------------------------------------------------------------- /patches/integration/30_1_editor_settings.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/js/background.js b/src/js/background.js 2 | index dc304bef..fc7c4497 100644 3 | --- a/src/js/background.js 4 | +++ b/src/js/background.js 5 | @@ -96,6 +96,8 @@ const µBlock = (( ) => { // jshint ignore:line 6 | hyperlinkAuditingDisabled: true, 7 | ignoreGenericCosmeticFilters: vAPI.webextFlavor.soup.has('mobile'), 8 | largeMediaSize: 50, 9 | + nanoEditorSoftWrap: false, 10 | + nanoViewerSoftWrap: true, 11 | parseAllABPHideFilters: true, 12 | popupPanelSections: 0b111, 13 | prefetchingDisabled: true, 14 | diff --git a/src/settings.html b/src/settings.html 15 | index dff29650..ee35eb80 100644 16 | --- a/src/settings.html 17 | +++ b/src/settings.html 18 | @@ -24,6 +24,8 @@ 19 |

20 |
21 |
22 | +
23 | +
24 | 25 |
26 |
27 | -------------------------------------------------------------------------------- /patches/integration/10_7_filter_editor.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/1p-filters.html b/src/1p-filters.html 2 | index 27a2c81d..44918086 100644 3 | --- a/src/1p-filters.html 4 | +++ b/src/1p-filters.html 5 | @@ -5,16 +5,12 @@ 6 | 7 | uBlock — Your filters 8 | 9 | - 10 | - 11 | - 12 | 13 | 14 | 15 | 16 | 17 | 18 | - 19 | 20 | 21 | 22 | @@ -36,15 +32,9 @@ 23 | 24 |
25 | 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | + 36 | + 37 | + 38 | 39 | 40 | 41 | @@ -54,7 +44,7 @@ 42 | 43 | 44 | 45 | - 46 | + 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /notes/filter_syntax.md: -------------------------------------------------------------------------------- 1 | # Filter Syntax 2 | 3 | If you are not familiar with filter syntax of uBlock Origin, 4 | [**please read this first**](https://github.com/gorhill/uBlock/wiki/Static-filter-syntax). 5 | 6 | In Nano Adblocker, most of the filter syntax are the same as uBlock Origin, 7 | however, there are a few exceptions. 8 | 9 | ## Extra Resources 10 | 11 | Nano Adblocker has 12 | [extra resources](https://github.com/NanoAdblocker/NanoCore2/blob/master/src/snippets.js), 13 | and when a filter references one of those resources, it will not work as 14 | intended in uBlock Origin out of the box. You can, however, load these extra 15 | resources to uBlock Origin in advanced settings to make those filters work. 16 | 17 | To combat extra stubborn websites, Nano Adblocker also has a few privileged 18 | resources. These resources, which start with `nanop-`, are very powerful 19 | so only privileged filters are allowed to use them. For security reasons, 20 | they will not work in uBlock Origin. 21 | 22 | ## Convenience Options 23 | 24 | Nano Adblocker and uBlock Origin will map options as follows for convenience: 25 | ``` 26 | 1p -> first-party 27 | 3p -> third-party 28 | css -> stylesheet 29 | doc -> document 30 | ehide -> elemhide 31 | frame -> subdocument 32 | ghide -> generichide 33 | shide -> specifichide 34 | xhr -> xmlhttprequest 35 | ``` 36 | 37 | Additionally, Nano Adblocker will map `iframe` to `subdocument`. uBlock Origin 38 | will discard filters that use the `iframe` option. 39 | 40 | ## The option `fetch` 41 | 42 | Nano Adblocker does not differentiate between `fetch` and `xmlhttprequest` 43 | requests and does not recognize `fetch` as an option. `fetch` requests 44 | are mapped to `xmlhttprequest` by Edgyfy. uBlock Origin on Edge differentiates 45 | between `fetch` and `xmlhttprequest` but does not recognize `fetch` as an 46 | option. 47 | 48 | If you are a filters maintainer and this difference is causing problems for 49 | you, please let us know. 50 | 51 | # Filter Editor 52 | 53 | Nano Editor is powered by Ace, and most 54 | [shortcut keys](https://github.com/ajaxorg/ace/wiki/Default-Keyboard-Shortcuts) 55 | are the same. 56 | -------------------------------------------------------------------------------- /src/js/nano-vapi.js: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------------------------------- // 2 | 3 | // Nano Core 2 - An adblocker 4 | // Copyright (C) 2018-2019 Nano Core 2 contributors 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | 19 | // ----------------------------------------------------------------------------------------------------------------- // 20 | 21 | // Platform binding 22 | 23 | // ----------------------------------------------------------------------------------------------------------------- // 24 | 25 | "use strict"; 26 | 27 | // ----------------------------------------------------------------------------------------------------------------- // 28 | 29 | var nAPI = nAPI || {}; 30 | 31 | // ----------------------------------------------------------------------------------------------------------------- // 32 | 33 | nAPI.add_public_api_handler = (trusted, handler) => { 34 | chrome.runtime.onMessageExternal.addListener((msg, sender, res) => { 35 | if (typeof msg !== "object" || msg === null) 36 | return; 37 | 38 | if (!trusted(sender.id)) 39 | return; 40 | 41 | if (!handler(msg)) 42 | return; 43 | 44 | // TODO: The handler function can return a Promise 45 | 46 | if (typeof res === "function") 47 | res({ data: "ok" }); 48 | }); 49 | }; 50 | 51 | // ----------------------------------------------------------------------------------------------------------------- // 52 | -------------------------------------------------------------------------------- /patches/20_5_other_editors_style.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/css/codemirror.css b/src/css/codemirror.css 2 | index 5d3eafdc..e0979efb 100644 3 | --- a/src/css/codemirror.css 4 | +++ b/src/css/codemirror.css 5 | @@ -22,7 +22,10 @@ 6 | word-break: break-all; 7 | } 8 | 9 | -.cm-s-default .cm-comment { color: #777; } 10 | +/* Order is important! */ 11 | +.cm-s-default .cm-nanokeyword { color: rgb(0, 0, 255); } 12 | +.cm-s-default .cm-comment { color: rgb(191, 191, 191); } 13 | +.cm-s-default .cm-error { background-color: rgba(255, 0, 0, 0.1); color: red; } 14 | .cm-directive { color: #333; font-weight: bold; } 15 | .cm-staticext { color: #008; } 16 | .cm-staticnetBlock { color: #800; } 17 | diff --git a/src/js/advanced-settings.js b/src/js/advanced-settings.js 18 | index 7c3ea045..fc992d3c 100644 19 | --- a/src/js/advanced-settings.js 20 | +++ b/src/js/advanced-settings.js 21 | @@ -45,7 +45,7 @@ CodeMirror.defineMode('raw-settings', function() { 22 | const match = stream.match(/\S+/); 23 | if ( match !== null && defaultSettings.has(match[0]) ) { 24 | lastSetting = match[0]; 25 | - return 'keyword'; 26 | + return 'nanokeyword'; 27 | } 28 | stream.skipToEnd(); 29 | return 'line-cm-error'; 30 | diff --git a/src/js/whitelist.js b/src/js/whitelist.js 31 | index 546308df..2db002d3 100644 32 | --- a/src/js/whitelist.js 33 | +++ b/src/js/whitelist.js 34 | @@ -52,13 +52,13 @@ CodeMirror.defineMode("ubo-whitelist-directives", function() { 35 | } 36 | if ( reComment.test(line) ) { 37 | return whitelistDefaultSet.has(directiveFromLine(line)) 38 | - ? 'keyword comment' 39 | + ? 'nanokeyword comment' 40 | : 'comment'; 41 | } 42 | if ( line.indexOf('/') === -1 ) { 43 | if ( reBadHostname.test(line) ) { return 'error'; } 44 | if ( whitelistDefaultSet.has(line.trim()) ) { 45 | - return 'keyword'; 46 | + return 'nanokeyword'; 47 | } 48 | return null; 49 | } 50 | -------------------------------------------------------------------------------- /patches/integration/10_8_filter_viewer.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/asset-viewer.html b/src/asset-viewer.html 2 | index 9d3eaedf..5768d38e 100644 3 | --- a/src/asset-viewer.html 4 | +++ b/src/asset-viewer.html 5 | @@ -4,12 +4,9 @@ 6 | 7 | 8 | 9 | - 10 | - 11 | 12 | 13 | 14 | - 15 | 16 |