Updated ContentBlockerHandler CSS_DISPLAY_NONE action type and JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_JS_SOURCE javascript implementation code
This commit is contained in:
parent
77bca50f0e
commit
35fea2c331
@ -1,3 +1,7 @@
|
||||
## 1.0.3
|
||||
|
||||
- Updated `ContentBlockerHandler` CSS_DISPLAY_NONE action type and `JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_JS_SOURCE` javascript implementation code
|
||||
|
||||
## 1.0.2
|
||||
|
||||
- Updated `flutter_inappwebview_platform_interface` version dependency to `1.0.2`
|
||||
|
@ -156,7 +156,7 @@ public class ContentBlockerHandler {
|
||||
final String cssSelector = action.getSelector();
|
||||
final String jsScript = "(function(d) { " +
|
||||
" function hide () { " +
|
||||
" if (!d.getElementById('" + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + "-css-display-none-style')) { " +
|
||||
" if (d.body != null && !d.getElementById('" + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + "-css-display-none-style')) { " +
|
||||
" var c = d.createElement('style'); " +
|
||||
" c.id = '" + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + "-css-display-none-style'; " +
|
||||
" c.innerHTML = '" + cssSelector + " { display: none !important; }'; " +
|
||||
|
@ -214,24 +214,27 @@ public class JavaScriptBridgeJS {
|
||||
" }" +
|
||||
"};";
|
||||
|
||||
public static final String JAVASCRIPT_BRIDGE_JS_SOURCE = "if (window.top == null || window.top === window) {" +
|
||||
" if (window." + JAVASCRIPT_BRIDGE_NAME + " != null) {" +
|
||||
" window." + JAVASCRIPT_BRIDGE_NAME + ".callHandler = function() {" +
|
||||
" var _callHandlerID = setTimeout(function(){});" +
|
||||
" window." + JAVASCRIPT_BRIDGE_NAME + "._callHandler(arguments[0], _callHandlerID, JSON.stringify(Array.prototype.slice.call(arguments, 1)));" +
|
||||
" return new Promise(function(resolve, reject) {" +
|
||||
" window." + JAVASCRIPT_BRIDGE_NAME + "[_callHandlerID] = {resolve: resolve, reject: reject};" +
|
||||
" });" +
|
||||
" };" +
|
||||
" }"+
|
||||
"} else {" +
|
||||
public static final String JAVASCRIPT_BRIDGE_JS_SOURCE = "if (window." + JAVASCRIPT_BRIDGE_NAME + " != null) {" +
|
||||
" window." + JAVASCRIPT_BRIDGE_NAME + ".callHandler = function() {" +
|
||||
" var _callHandlerID = setTimeout(function(){});" +
|
||||
" window." + JAVASCRIPT_BRIDGE_NAME + "._callHandler(arguments[0], _callHandlerID, JSON.stringify(Array.prototype.slice.call(arguments, 1)));" +
|
||||
" return new Promise(function(resolve, reject) {" +
|
||||
" window." + JAVASCRIPT_BRIDGE_NAME + "[_callHandlerID] = {resolve: resolve, reject: reject};" +
|
||||
" });" +
|
||||
" };" +
|
||||
"}"+
|
||||
"if (window.top != null && window.top !== window && window." + JAVASCRIPT_BRIDGE_NAME + " == null) {" +
|
||||
" window." + JAVASCRIPT_BRIDGE_NAME + " = {};" +
|
||||
" window." + JAVASCRIPT_BRIDGE_NAME + ".callHandler = function() {" +
|
||||
" var _callHandlerID = setTimeout(function(){});" +
|
||||
" window.top." + JAVASCRIPT_BRIDGE_NAME + "._callHandler(arguments[0], _callHandlerID, JSON.stringify(Array.prototype.slice.call(arguments, 1)));" +
|
||||
" return new Promise(function(resolve, reject) {" +
|
||||
" window.top." + JAVASCRIPT_BRIDGE_NAME + "[_callHandlerID] = {resolve: resolve, reject: reject};" +
|
||||
" });" +
|
||||
" try {" +
|
||||
" window.top." + JAVASCRIPT_BRIDGE_NAME + "._callHandler(arguments[0], _callHandlerID, JSON.stringify(Array.prototype.slice.call(arguments, 1)));" +
|
||||
" return new Promise(function(resolve, reject) {" +
|
||||
" window.top." + JAVASCRIPT_BRIDGE_NAME + "[_callHandlerID] = {resolve: resolve, reject: reject};" +
|
||||
" });" +
|
||||
" } catch (error) {" +
|
||||
" return new Promise(function(resolve, reject) { reject(error); });" +
|
||||
" }" +
|
||||
" };" +
|
||||
"}" +
|
||||
"if (window." + JAVASCRIPT_BRIDGE_NAME + " != null) {" +
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: flutter_inappwebview_android
|
||||
description: Android implementation of the flutter_inappwebview plugin.
|
||||
version: 1.0.2
|
||||
version: 1.0.3
|
||||
homepage: https://inappwebview.dev/
|
||||
repository: https://github.com/pichillilorenzo/flutter_inappwebview/tree/master/flutter_inappwebview_android
|
||||
issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues
|
||||
|
Loading…
x
Reference in New Issue
Block a user