Release 66.0.3359.202

This commit is contained in:
csagan5 2018-05-29 20:52:06 +02:00
parent ea53ed1889
commit aac51e0a5a
4 changed files with 1715 additions and 162 deletions

View file

@ -1,3 +1,8 @@
# 66.0.3359.202
* fix DevTools integration (https://github.com/bromite/bromite/issues/23)
* allow toggling of Javascript from New Tab Page (fixes https://github.com/bromite/bromite/issues/60)
* updated AdBlock filters
# 66.0.3359.200
* updated AdBlock filters

File diff suppressed because it is too large Load diff

View file

@ -65,7 +65,7 @@ new file mode 100644
+#ifndef anti_amp_cure_h
+#define anti_amp_cure_h
+
+#define ANTI_AMP_CURE_JS "/* Bromite click-tracking and AMP removal v0.3.5 */\n\nfunction recreateHyperlink(a) {\n // skip already-sanitized hyperlinks\n if (a.sane) return false;\n\n // create new A element - old one has event listeners attached\n var newA = document.createElement('a');\n newA.referrerPolicy = 'origin';\n // property set when hyperlink has been created by this script\n newA.sane = 1;\n\n // remove AMP class, get actual page URL\n var ampCur = a.getAttribute('data-amp-cur');\n if (ampCur) {\n newA.href = ampCur;\n a.classList.remove('amp_r');\n } else {\n var realLink = getRealLinkFromGoogleUrl(a);\n if (realLink) {\n newA.href = realLink;\n } else {\n // might not be an actual hyperlink, ignore it\n if (!a.href) {\n return false;\n }\n // leave original href unchanged\n newA.href = a.href;\n }\n }\n // copy CSS classes\n newA.className = a.className;\n\n // copy nodes inside the hyperlink\n while (a.firstChild) {\n newA.appendChild(a.lastChild);\n }\n // replace hyperlink\n a.parentNode.replaceChild(newA, a);\n return true;\n}\n\nfunction isResult(a) {\n if (a.getAttribute('data-amp-cur'))\n return true;\n var inlineMousedown = a.getAttribute('onmousedown');\n if (!inlineMousedown)\n\treturn false;\n // return rwt(....); // E.g Google search results.\n // return google.rwt(...); // E.g. sponsored search results\n // return google.arwt(this); // E.g. sponsored search results (dec 2016).\n return /\\ba?rwt\\(/.test(inlineMousedown) || /\\bctpacw\\b/.test(inlineMousedown);\n}\n\n/**\n * @returns {String} the real URL if the given link is a Google redirect URL.\n */\nfunction getRealLinkFromGoogleUrl(a) {\n if ((a.hostname === location.hostname || a.hostname.indexOf('www.google.') == 0) &&\n /^\\/(local_)?url$/.test(a.pathname)) {\n // Google Maps / Dito (/local_url?q=<url>)\n // Mobile (/url?q=<url>)\n var url = /[?&](?:q|url)=((?:https?|ftp)[%:][^&]+)/.exec(a.search);\n if (url) {\n return decodeURIComponent(url[1]);\n }\n // Help pages, e.g. safe browsing (/url?...&q=%2Fsupport%2Fanswer...)\n url = /[?&](?:q|url)=((?:%2[Ff]|\\/)[^&]+)/.exec(a.search);\n if (url) {\n return a.origin + decodeURIComponent(url[1]);\n }\n }\n}\n\nfunction sanitizeAds() {\n // scan all divs\n var div = document.getElementById('tads');\n if (div) {\n div.style.display = 'none';\n\treturn true;\n }\n return false;\n}\n\nfunction sanitizeAll() {\n console.log(\"ads removed: \", sanitizeAds());\n console.log(\"hyperlinks sanitized: \", sanitizeAllHyperlinks());\n}\n\nfunction setMlogoClick() {\n var mlogo = document.getElementById('mlogo');\n if (mlogo) {\n mlogo.removeAttribute(\"href\");\n mlogo.setAttribute(\"onclick\", \"sanitizeAll()\");\n console.log(\"logo link replaced\");\n } else {\n console.log(\"could not replace logo link\");\n }\n}\n\nfunction sanitizeAllHyperlinks() {\n var saned = 0, total = 0;\n document.querySelectorAll('div[data-hveid]:not([data-hveid=\"\"]) a').forEach(function(a) {\n\ttotal++;\n\tvar res = recreateHyperlink(a);\n\tif (res) saned++;\n });\n console.log(\"sanitized \", saned, \"/\", total, \" hyperlinks\");\n\n return saned;\n}\n\n// avoid running cleanup on non-search pages\nif ((document.location.host.indexOf(\"images.google.\") == -1) && (document.location.host.indexOf(\"news.google.\") == -1)) {\n// document.addEventListener('touchstart', handlePointerPress, true);\n sanitizeAll();\n}\nsetMlogoClick();\n"
+#define ANTI_AMP_CURE_JS "/* Bromite click-tracking and AMP removal v0.3.5 */\n\nfunction recreateHyperlink(a) {\n // skip already-sanitized hyperlinks\n if (a.sane) return false;\n\n // create new A element - old one has event listeners attached\n var newA = document.createElement('a');\n newA.referrerPolicy = 'origin';\n // property set when hyperlink has been created by this script\n newA.sane = 1;\n\n // remove AMP class, get actual page URL\n var ampCur = a.getAttribute('data-amp-cur');\n if (ampCur) {\n newA.href = ampCur;\n a.classList.remove('amp_r');\n } else {\n var realLink = getRealLinkFromGoogleUrl(a);\n if (realLink) {\n newA.href = realLink;\n } else {\n // might not be an actual hyperlink, ignore it\n if (!a.href) {\n return false;\n }\n // leave original href unchanged\n newA.href = a.href;\n }\n }\n // copy CSS classes\n newA.className = a.className;\n\n // copy nodes inside the hyperlink\n while (a.firstChild) {\n newA.appendChild(a.lastChild);\n }\n // replace hyperlink\n a.parentNode.replaceChild(newA, a);\n return true;\n}\n\nfunction isResult(a) {\n if (a.getAttribute('data-amp-cur'))\n return true;\n var inlineMousedown = a.getAttribute('onmousedown');\n if (!inlineMousedown)\n\treturn false;\n // return rwt(....); // E.g Google search results.\n // return google.rwt(...); // E.g. sponsored search results\n // return google.arwt(this); // E.g. sponsored search results (dec 2016).\n return /\\ba?rwt\\(/.test(inlineMousedown) || /\\bctpacw\\b/.test(inlineMousedown);\n}\n\n/**\n * @returns {String} the real URL if the given link is a Google redirect URL.\n */\nfunction getRealLinkFromGoogleUrl(a) {\n if ((a.hostname === location.hostname || a.hostname.indexOf('www.google.') == 0) &&\n /^\\/(local_)?url$/.test(a.pathname)) {\n // Google Maps / Dito (/local_url?q=<url>)\n // Mobile (/url?q=<url>)\n var url = /[?&](?:q|url)=((?:https?|ftp)[%:][^&]+)/.exec(a.search);\n if (url) {\n return decodeURIComponent(url[1]);\n }\n // Help pages, e.g. safe browsing (/url?...&q=%2Fsupport%2Fanswer...)\n url = /[?&](?:q|url)=((?:%2[Ff]|\\/)[^&]+)/.exec(a.search);\n if (url) {\n return a.origin + decodeURIComponent(url[1]);\n }\n }\n}\n\nfunction sanitizeAds() {\n // scan all divs\n var div = document.getElementById('tads');\n if (div) {\n div.style.display = 'none';\n\treturn true;\n }\n return false;\n}\n\nfunction sanitizeAll() {\n console.log(\"ads removed: \", sanitizeAds());\n console.log(\"hyperlinks sanitized: \", sanitizeAllHyperlinks(document));\n}\n\nfunction hookMoreResults() {\n var extrares = document.getElementById('extrares');\n if (!extrares) {\n console.log(\"could not hook more results\");\n return;\n }\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(n) {\n console.log(\"hyperlinks sanitized on new result node: \", sanitizeAllHyperlinks(n));\n });\n });\n });\n observer.observe(extrares, {childList: true});\n}\n\nfunction setMlogoClick() {\n var mlogo = document.getElementById('qslc');\n if (mlogo && mlogo.children[0]) {\n mlogo = mlogo.children[0];\n mlogo.removeAttribute(\"href\");\n mlogo.setAttribute(\"onclick\", \"sanitizeAll()\");\n console.log(\"logo link replaced\");\n } else {\n console.log(\"could not replace logo link\");\n }\n}\n\nfunction sanitizeAllHyperlinks(rootNode) {\n var saned = 0, total = 0;\n rootNode.querySelectorAll('div[data-hveid]:not([data-hveid=\"\"]) a').forEach(function(a) {\n\ttotal++;\n\tvar res = recreateHyperlink(a);\n\tif (res) saned++;\n });\n console.log(\"sanitized \", saned, \"/\", total, \" hyperlinks\");\n\n return saned;\n}\n\n// avoid running cleanup on non-search pages\nif ((document.location.host.indexOf(\"images.google.\") == -1) && (document.location.host.indexOf(\"news.google.\") == -1)) {\n sanitizeAll();\n}\nsetMlogoClick();\n\nhookMoreResults();\n"
+
+#endif // anti_amp_cure_h
--

View file

@ -7,10 +7,10 @@ Subject: Add menu option to toggle global Javascript preference
chrome/android/java/res/menu/main_menu.xml | 13 ++++++++
.../chromium/chrome/browser/ChromeActivity.java | 8 +++++
.../chrome/browser/ChromeTabbedActivity.java | 8 +++++
.../browser/appmenu/AppMenuPropertiesDelegate.java | 35 ++++++++++++++++++++++
.../browser/appmenu/AppMenuPropertiesDelegate.java | 37 ++++++++++++++++++++++
.../CustomTabAppMenuPropertiesDelegate.java | 1 +
.../java/strings/android_chrome_strings.grd | 11 +++++++
7 files changed, 89 insertions(+)
7 files changed, 91 insertions(+)
diff --git a/chrome/android/java/res/menu/custom_tabs_menu.xml b/chrome/android/java/res/menu/custom_tabs_menu.xml
--- a/chrome/android/java/res/menu/custom_tabs_menu.xml
@ -106,7 +106,7 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/appmenu/AppMenu
// Only display reader mode settings menu option if the current page is in reader mode.
menu.findItem(R.id.reader_mode_prefs_id)
.setVisible(DomDistillerUrlUtils.isDistilledPage(currentTab.getUrl()));
@@ -468,4 +470,37 @@ public class AppMenuPropertiesDelegate {
@@ -468,4 +470,39 @@ public class AppMenuPropertiesDelegate {
return chromeHomeMenuItemFlagEnabled && !sHideChromeHomeMenuItems;
}
@ -123,12 +123,14 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/appmenu/AppMenu
+ MenuItem enableMenuLabel = menu.findItem(R.id.enable_javascript_id);
+ MenuItem enableMenuCheck = menu.findItem(R.id.enable_javascript_check_id);
+
+ // Hide enable javascript on all chrome:// pages and the NTP.
+ // Hide enable javascript on all chrome:// pages except for the NTP.
+ String url = currentTab.getUrl();
+ boolean isChromeScheme = url.startsWith(UrlConstants.CHROME_URL_PREFIX)
+ || url.startsWith(UrlConstants.CHROME_NATIVE_URL_PREFIX);
+ // Also hide enable javascsript on Reader Mode.
+ boolean isDistilledPage = DomDistillerUrlUtils.isDistilledPage(url);
+
+ boolean itemVisible = !isChromeScheme && !currentTab.isNativePage();
+ boolean itemVisible = (!isChromeScheme || currentTab.isNativePage()) && !isDistilledPage;
+ enableMenuRow.setVisible(itemVisible);
+ if (!itemVisible) return;
+