Method for automatically calling ActiveX plug-in by Web page based on browser extension
By injecting JavaScript scripts into the browser, the function of automatically calling ActiveX plug-ins on the web page is solved, which solves the problem of not being able to use ActiveX plug-ins in modern browsers, and realizes the function of using ActiveX plug-ins without upgrading and transformation of the Web system.
Patent Information
- Application Number
- CN202411666397.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-21
- Publication Date
- 2025-02-25
AI Technical Summary
As Microsoft stops supporting IE browser, many web systems that rely on ActiveX plug-ins cannot run normally in modern browsers. The existing technology requires upgrading and transformation of the original web system, which increases the economic cost of users. For web systems that cannot find maintenance units, upgrading and transformation is unrealistic.
Through browser extension technology, JavaScript scripts are injected, object elements of the web pages are traversed, attribute information is extracted, ActiveX plug-in containers and proxy objects are created, event response functions are rewrite, and the location and status of ActiveX plug-in containers and the object elements of the web page are synchronized, thus realizing the function of automatically calling ActiveX plug-in on the web page.
Without upgrading and remodeling the original web system, ActiveX plug-ins can be used in modern browsers such as Google, Firefox, Edge, and 360, which reduces the economic costs of users and solves the problem of not being able to implement the application of Web systems in modern browsers.
Smart Images

Figure CN119512652A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of browser extension and browser plug-in, and in particular to a method for realizing automatic calling of ActiveX plug-in by a Web page based on browser extension. Explanation of terms
[0002] Active X plug-in: Microsoft's name for a series of strategic object-oriented programming technologies and tools, the main technology of which is the Component Object Model (COM), which is equivalent to the terms Active X plug-in in this article. Only Microsoft IE browser supports Active X plug-in, but Microsoft will stop supporting IE browser at 21:00 on June 15, 2022.
[0003] Browser extensions: Also known as add-ons, they are small applications used to enhance browser functionality. They are implemented through technologies such as HTML, CSS, and JavaScript, and can add or modify browser functionality to provide specialized experiences or features that are important to the target audience. Currently, mainstream browsers such as Chrome, Edge, 360, and Firefox all support extension technology; Technical Background
[0004] As Microsoft stops supporting IE browser, the once popular IE browser has left the stage of history, and the latest browsers such as Google and Firefox no longer support plug-in technology. This has resulted in a large number of ActiveX plug-ins that were once safe, reliable, convenient and easy to use becoming unusable. Currently, some manufacturers use browser plug-in middleware technology to implement modern browsers to apply ActiveX plug-ins, but this requires the original Web system to be upgraded and transformed. For users with limited funds or even unable to find a maintenance unit, upgrading and transforming the original Web system is unrealistic.
[0005] Therefore, there is an urgent need for a technology that can enable the original Web system to call ActiveX plug-ins and use them in browsers such as Google and Firefox without upgrading or modification.
[0006] Disadvantages of traditional products: At present, in order to enable the original Web system call plug-in to be used in browsers such as Google Firefox, browser middleware technology is generally used to upgrade and transform the original system, which increases the economic cost of users; and for some Web systems that cannot find a maintenance unit, it will be impossible to realize the application of the Web system in browsers such as Google Firefox.
[0007] Purpose of the present invention: The present invention overcomes the shortcomings of the prior art and provides a method for realizing automatic calling of ActiveX plug-ins by Web pages based on browser extension, so that the original Web business system that calls ActiveX plug-ins can be applied on browsers such as Google, Firefox, Edge, 360, etc. without modification or upgrading. Summary of the invention
[0008] The present invention overcomes the deficiencies of the prior art and provides a method for automatically calling an ActiveX plug-in on a Web page based on browser extension. The technical solution of the present invention is as follows: A method for automatically calling an ActiveX plug-in on a Web page based on browser extension, characterized by comprising: S1: injecting a browser extension script; S2: traversing the object element of the Web page and extracting object element attribute information; S3: creating the ActiveX plug-in container and registering the Web page response event function; S4: creating the ActiveX plug-in and instantiating the ActiveX plug-in proxy object; S5: rewriting the Web page ActiveX plug-in event response function; S6: synchronizing the position and status of the ActiveX plug-in container and the Web page object element.
[0009] Wherein, the step S1 includes the following steps: injecting the browser extension script. Injecting the ActiveX plug-in management module JavaScript script, the ActiveX plug-in proxy module JavaScript script and the business module JavaScript script into the browser web page according to the browser extension specification. Adjusting the browser extension security policy so that the above JavaScript script has the permission to access the browser web page DOM element; Further, the ActiveX plug-in management module realizes the creation, window positioning, and destruction of the ActiveX plug-in container; realizes the creation, event callback, and destruction of the ActiveX plug-in; Furthermore, the ActiveX plug-in proxy class module encapsulates the properties and methods consistent with the ActiveX plug-in, and the properties and methods of the ActiveX plug-in proxy class module call the properties and methods consistent with the ActiveX plug-in through network transfer. The browser instantiates the ActiveX plug-in proxy class module object obj, and calls the properties and methods corresponding to the ActiveX plug-in by calling the properties and methods of the aforementioned object obj; Furthermore, the business module, as an injection script execution entry, implements the Web page object element traversal, the ActiveX plug-in management module initialization, the ActiveX plug-in proxy class instantiation and the ActiveX plug-in event response function call.
[0010] Wherein, the step S2 includes the following steps: traversing the object element of the Web page and extracting the attribute information of the object element. In the JavaScript script of the business module, traversing the object element of the Web page, if the object element does not exist, then no processing is performed; otherwise, all attribute names and attribute values of the object element are extracted; Furthermore, the above object element attributes must contain the classid attribute. If it does not exist, it will not be processed.
[0011] The step S3 includes the following steps: creating the ActiveX plug-in container and registering the Web page response event function. Using the Web page object element in step S2 as a parameter, calling the ActiveX plug-in management module to create a plug-in container interface, creating the ActiveX plug-in container, and associating the ActiveX plug-in container with the Web page object element; using the ActiveX plug-in management module event registration interface to register a page response event and respond to the ActiveX plug-in event; Furthermore, the registered event name is consistent with the ActiveX plug-in event name. When there are multiple events, the event names are separated by semicolons.
[0012] The step S4 includes the following steps: creating the ActiveX plug-in and instantiating the ActiveX plug-in proxy object. According to the value of the classid attribute of the object element in the step S2, calling the ActiveX plug-in management module interface to create the ActiveX plug-in, if the creation fails, terminating the instantiation of the ActiveX plug-in proxy object; otherwise, obtaining the ActiveX plug-in handle h. Through the ActiveX plug-in proxy class module, using the handle h as a parameter to instantiate the ActiveX plug-in proxy object OBJ; Preferably, when a Web page accesses the ActiveX plug-in properties and methods through an object with the same name as the object element attribute id value, it is necessary to add an attribute A with the same name as the object element attribute id value to the Web page window object, and assign the Web page window object attribute A to the ActiveX plug-in proxy object OBJ; Preferably, when a Web page obtains an object through the getElementById method of the document object to access the ActiveX plug-in properties and methods, the getElementById method of the document object needs to be intercepted. When the id parameter of the getElementById method is equal to the object element id, the ActiveX plug-in proxy object OBJ is returned; when the id parameter of the getElementById method is not equal to the object element id, the original process of the getElementById method is used to return the result to avoid affecting the original business.
[0013] Wherein, the step S5 includes the following steps: rewriting the ActiveX plug-in event response function. Since the browser of Html5 specification does not support the IE browser ActiveX plug-in event response mechanism, it is necessary to rewrite the ActiveX plug-in event response function. According to the name and parameters of the Web page response function, add a function F with the same name and parameters in the business module; and the execution script of the Web page response function is consistent with the execution script in the above function F; Preferably, the ActiveX plug-in management module will monitor the ActiveX plug-in event in real time. When the ActiveX plug-in event is triggered, it will determine whether there is an event response function F on the Web page. If not, no processing will be performed; otherwise, the above function F will be called.
[0014] Wherein, the step S6 includes the following steps: synchronizing the position and status of the ActiveX plug-in container and the Web page object element. According to the association relationship between the ActiveX plug-in container and the Web page object element in the step S3, the ActiveX plug-in management module periodically obtains the position and display status of the Web page object element, and adjusts the position and display status of the associated ActiveX plug-in container. When the Web page object element is displayed, the associated ActiveX plug-in container is seamlessly embedded in the Web page object element position according to the object element position information; when the Web page object element is hidden, the associated ActiveX plug-in container is hidden; when the detection page is closed, the associated ActiveX plug-in container and the ActiveX plug-in are destroyed. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 It is a structural principle diagram of the present invention; Figure 2It is a flow chart of the method principle of the present invention; Figure 3 A specific embodiment of the present invention is to inject a JavaScript script into a Chrome browser extension; Figure 4 It is the iWebPDF2018 plug-in proxy class module code of a specific embodiment of the present invention; Figure 5 It is the code for creating a plug-in container and registering an ActiveX plug-in event in a specific embodiment of the present invention; Figure 6 A specific embodiment of the present invention creates an iWebPDF2018 plug-in and instantiates an iWebPDF2018 plug-in proxy object; Figure 7 It is a specific embodiment of the present invention, a web page accesses the iWebPDF2018 plug-in properties and methods; Figure 8 It is a specific embodiment of the present invention to rewrite the iWebPDF2018 plug-in event response function; Fig. 9 This is the effect of not installing the allWebPlugin extension in Google Chrome, iWebPDF2018 plug-in, a specific embodiment of the present invention; Fig.10 This is the effect of installing and enabling the allWebPlugin extension in Google Chrome, iWebPDF2018 plug-in, a specific embodiment of the present invention; Specific implementation methods
[0016] The specific implementation of the present invention will be further described in detail below in conjunction with the accompanying drawings and examples. This specific embodiment uses the Chrome browser, allWebPlugin middleware and Jinge iWebPDF2018 plug-in for specific description. The following examples are used to illustrate the present invention, but are not used to limit the scope of the present invention.
[0017] See also Figure 1 The present invention provides a structural principle diagram for realizing automatic calling of ActiveX plug-ins by Web pages based on browser extension.
[0018] See also Figure 2The present invention provides a flow chart of a method for realizing automatic calling of an ActiveX plug-in by a Web page based on a browser extension, comprising the following steps: S1: injecting a browser extension script; S2: traversing the object element of the Web page and extracting object element attribute information; S3: creating the ActiveX plug-in container and registering the Web page response event function; S4: creating the ActiveX plug-in and instantiating the ActiveX plug-in proxy object; S5: rewriting the Web page ActiveX plug-in event response function; S6: synchronizing the position and status of the ActiveX plug-in container and the Web page object element.
[0019] Specifically, step S1 includes the following steps: injecting the browser extension script. Injecting the ActiveX plug-in management module JavaScript script, the ActiveX plug-in proxy module JavaScript script and the business module JavaScript script into the browser web page according to the browser extension specification. Adjusting the browser extension security policy so that the above JavaScript script has the permission to access the browser web page DOM element; like Figure 3 As shown, a more specific embodiment is described, the Chrome browser loads the extension and injects the JavaScript script; like Figure 4 As shown, a more specific embodiment is described, and the iWebPDF2018 plug-in proxy class module is written.
[0020] Specifically, step S2 includes the following steps: traversing the object element of the Web page and extracting the attribute information of the object element. In the JavaScript script of the business module, traversing the object element of the Web page, if the object element does not exist, then the subsequent steps are not processed; otherwise, all the attribute names and attribute values of the object element are extracted; Furthermore, the above object element attributes must contain a classid attribute. If it does not exist, the subsequent steps will not be processed.
[0021] Specifically, the step S3 includes the following steps: creating the ActiveX plug-in container and registering the Web page response event function. Taking the Web page object element in the step S2 as a parameter, calling the ActiveX plug-in management module to create a plug-in container interface, creating the ActiveX plug-in container, and realizing the association between the ActiveX plug-in container and the Web page object element; using the ActiveX plug-in management module event registration interface to register a page response event and respond to the ActiveX plug-in event; Furthermore, the registered event name is consistent with the ActiveX plug-in event name, and when there are multiple events, the event names are separated by semicolons; A more specific embodiment is described as follows. Figure 5 As shown, the Web page object element is used as a parameter, the createContainer method of the allWebPlugin middleware object is called to create a plug-in container object, and the OnToolsClick event of the iWebPDF2018 plug-in is registered.
[0022] Specifically, the step S4 includes the following steps: creating the ActiveX plug-in and instantiating the ActiveX plug-in proxy object. According to the value of the classid attribute of the object element in the step S2, calling the ActiveX plug-in management module interface to create the ActiveX plug-in, if the creation fails, then terminating the instantiation of the ActiveX plug-in proxy object; otherwise, obtaining the ActiveX plug-in handle h, and instantiating the ActiveX plug-in proxy object OBJ by using the handle h as a parameter through the ActiveX plug-in proxy class module; A more specific embodiment is described as follows. Figure 6 As shown, the classid attribute value is used as a parameter, the createPlugin method of the hostCnt object of the allWebPlugin middleware plug-in container is called to create the iWebPDF2018 plug-in; the iWebPDF2018 plug-in handle is used as a parameter to instantiate the plug-in proxy object.
[0023] Preferably, when a Web page accesses the ActiveX plug-in properties and methods through an object with the same name as the object element attribute id value, it is necessary to add an attribute A with the same name as the object element attribute id value to the Web page window object, and assign the Web page window object attribute A to the ActiveX plug-in proxy object OBJ; A more specific embodiment is described as follows. Figure 7 As shown, the object element attribute id value is A, the window object will add attribute A, and the ActiveX plug-in proxy object OBJ is assigned to the window object attribute A; Preferably, when a Web page obtains an object through the getElementById method of the document object to access the ActiveX plug-in properties and methods, the getElementById method of the document object needs to be intercepted. When the id parameter of the getElementById method is equal to the object element id, the ActiveX plug-in proxy object OBJ is returned; when the id parameter of the getElementById method is not equal to the object element id, the original process of the getElementById method is used to return the result to avoid affecting the original business; A more specific embodiment is described as follows. Figure 7 As shown, the ActiveX plug-in proxy object OBJ is obtained through getElementById of the document object.
[0024] Specifically, the step S5 includes the following steps: rewriting the ActiveX plug-in event response function. Since the browser of Html5 specification does not support the IE browser ActiveX plug-in event response mechanism, it is necessary to rewrite the ActiveX plug-in event response function. According to the name and parameters of the Web page response function, add a function F with the same name and parameters in the business module; and the execution script of the Web page response function is consistent with the execution script in the above function F; Preferably, the ActiveX plug-in management module will monitor the ActiveX plug-in event in real time. When the ActiveX plug-in event is triggered, it will determine whether the Web page has an event response function F. If not, it will not be processed; otherwise, the above function F will be called; A more specific embodiment is described as follows. Figure 8 As shown, the web page rewrites the OnToolsClick event response function of the iWebPDF2018 plug-in.
[0025] Specifically, the step S6 includes the following steps: synchronizing the position and status of the ActiveX plug-in container and the Web page object element. According to the association relationship between the ActiveX plug-in container and the object element in step S3, the ActiveX plug-in management module periodically obtains the position and display status of the Web page object element, and adjusts the position and display status of the associated ActiveX plug-in container. When the Web page object element is displayed, the associated ActiveX plug-in container is seamlessly embedded into the Web page object element position according to the object element position information; when the Web page object element is hidden, the associated ActiveX plug-in container is hidden; when the detection page is closed, the associated ActiveX plug-in container and the ActiveX plug-in are destroyed; To describe in a more specific embodiment, the ActiveX plug-in management module periodically monitors the position and display status of the Web page object element, and sends the above position and display status information to the allWebPlugin middleware. The allWebPlugin middleware adjusts the position and display status of the ActiveX plug-in container. When the Web page object element is displayed, the associated ActiveX plug-in container is seamlessly embedded in the Web page object element position according to the object element position information; when the Web page object element is hidden, the associated ActiveX plug-in container is hidden; the ActiveX plug-in management module monitors the Web page beforeunload event, and when the aforementioned beforeunload event is triggered, the ActiveX plug-in container and the ActiveX plug-in are destroyed in time.
Claims
1. A method for automatically calling an ActiveX plug-in on a web page based on browser extension, characterized in that: The steps include: S1: Inject browser extension script; S2: traverse the object elements of the Web page and extract object element attribute information; S3: Create the ActiveX plug-in container and register the Web page response event function; S4: creating the ActiveX plug-in and instantiating the ActiveX plug-in proxy object; S5: rewrite the Web page ActiveX plug-in event response function; S6: Synchronize the position and status of the ActiveX plug-in container and the Web page object element.
2. The method for implementing automatic calling of ActiveX plug-ins by web pages based on browser extension according to claim 1, characterized in that: The step S1 includes the following steps: injecting the browser extension script. Injecting the ActiveX plug-in management module JavaScript script, the ActiveX plug-in proxy module JavaScript script and the business module JavaScript script into the browser web page according to the browser extension specification. Adjusting the browser extension security policy so that the above JavaScript script has the permission to access the browser web page DOM element.
3. The method for implementing automatic calling of ActiveX plug-ins by web pages based on browser extension according to claim 1, characterized in that: The step S2 includes the following steps: traversing the object element of the Web page and extracting the attribute information of the object element. In the JavaScript script of the business module, traversing the object element of the Web page, if the object element does not exist, then not processing; otherwise, extracting all the attribute names and attribute values of the object element. The aforementioned object element attributes must include the classid attribute, if not, then not processing.
4. The method for implementing automatic calling of ActiveX plug-ins by web pages based on browser extension according to claim 1, characterized in that: The step S3 includes the following steps: creating the ActiveX plug-in container and registering the Web page response event function. Using the Web page object element in step S2 as a parameter, calling the ActiveX plug-in management module to create a plug-in container interface, creating the ActiveX plug-in container, and realizing the association between the ActiveX plug-in container and the Web page object element; using the ActiveX plug-in management module event registration interface to register a page response event and respond to the ActiveX plug-in event; The registered event name is consistent with the ActiveX plug-in event name. When there are multiple events, the event names are separated by semicolons.
5. The method for implementing automatic calling of ActiveX plug-ins by web pages based on browser extension according to claim 1, characterized in that: The step S4 includes the following steps: creating the ActiveX plug-in and instantiating the ActiveX plug-in proxy object. According to the value of the classid attribute of the object element in the step S2, calling the ActiveX plug-in management module interface to create the ActiveX plug-in, if the creation fails, terminating the instantiation of the ActiveX plug-in proxy object; otherwise, obtaining the ActiveX plug-in handle h. Through the ActiveX plug-in proxy class module, using the handle h as a parameter to instantiate the ActiveX plug-in proxy object OBJ; When a Web page accesses the ActiveX plug-in properties and methods through the object with the same name as the object element attribute id value, it is necessary to add an attribute A with the same name as the object element attribute id value to the Web page window object, and assign the Web page window object attribute A to the ActiveX plug-in proxy object OBJ; When a Web page obtains an object through the getElementById method of the document object to access the properties and methods of the ActiveX plug-in, the getElementById method of the document object needs to be intercepted. When the id parameter of the getElementById method is equal to the object element id, the ActiveX plug-in proxy object OBJ is returned; when the id parameter of the getElementById method is not equal to the object element id, the original process of the getElementById method is used to return the result to avoid affecting the original business.
6. The method for implementing automatic calling of ActiveX plug-ins by a web page based on browser extension according to claim 1, characterized in that: The step S5 includes the following steps: rewriting the ActiveX plug-in event response function. According to the name and parameters of the Web page response function, adding a function F with the same name and parameters in the business module; and the Web page response function execution script is consistent with the execution script in the above function F; The ActiveX plug-in management module will monitor the ActiveX plug-in event in real time. When the ActiveX plug-in event is triggered, it will determine whether there is an event response function F on the Web page. If not, it will not be processed; otherwise, the above function F will be called.
7. The method for implementing automatic calling of ActiveX plug-ins by web pages based on browser extension according to claim 1, characterized in that: The step S6 includes the following steps: synchronizing the position and status of the ActiveX plug-in container and the Web page object element. According to the association relationship between the ActiveX plug-in container and the Web page object element in step S3, the ActiveX plug-in management module periodically obtains the position and display status of the Web page object element, and adjusts the position and display status of the associated ActiveX plug-in container. When the Web page object element is displayed, the associated ActiveX plug-in container is seamlessly embedded in the Web page object element position according to the object element position information; when the Web page object element is hidden, the associated ActiveX plug-in container is hidden; when the detection page is closed, the associated ActiveX plug-in container and the ActiveX plug-in are destroyed.