-
-
Notifications
You must be signed in to change notification settings - Fork 7
feat(HikVision): add remove plugin function #797
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -44,7 +44,21 @@ const hackJSDestroyPlugin = function () { | |||||||||||||||||||||
| return origianlSendRequestProxy.call(this, r); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| return this.oPlugin.JS_DestroyPlugin(true); | ||||||||||||||||||||||
| this.oPlugin.JS_DestroyPlugin(true); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| JSVideoPlugin = null; | ||||||||||||||||||||||
| delete window.JSVideoPlugin; | ||||||||||||||||||||||
| removePlugin(); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const removePlugin = () => { | ||||||||||||||||||||||
| const scripts = [...document.head.querySelectorAll('script')] | ||||||||||||||||||||||
| const nodes = scripts.filter(function (link) { | ||||||||||||||||||||||
| return link.src.indexOf('/jsVideoPlugin-1.0.0.min.js') > -1 | ||||||||||||||||||||||
|
||||||||||||||||||||||
| return link.src.indexOf('/jsVideoPlugin-1.0.0.min.js') > -1 | |
| return /\/jsVideoPlugin.*\.js$/.test(link.src); |
Copilot
AI
Dec 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable name link in the filter callback is misleading since the elements being filtered are <script> elements, not <link> elements. Consider renaming to script for clarity.
| const nodes = scripts.filter(function (link) { | |
| return link.src.indexOf('/jsVideoPlugin-1.0.0.min.js') > -1 | |
| const nodes = scripts.filter(function (script) { | |
| return script.src.indexOf('/jsVideoPlugin-1.0.0.min.js') > -1 |
Copilot
AI
Dec 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolons after statements on lines 56 and 57. Consider adding semicolons for consistency with the rest of the codebase (lines 47, 49, 50, 51, etc.).
| const scripts = [...document.head.querySelectorAll('script')] | |
| const nodes = scripts.filter(function (link) { | |
| return link.src.indexOf('/jsVideoPlugin-1.0.0.min.js') > -1 | |
| }) | |
| const scripts = [...document.head.querySelectorAll('script')]; | |
| const nodes = scripts.filter(function (link) { | |
| return link.src.indexOf('/jsVideoPlugin-1.0.0.min.js') > -1 | |
| }); |
Copilot
AI
Dec 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon after the closing brace. Consider adding a semicolon for consistency with the rest of the codebase.
| }) | |
| }); |
Copilot
AI
Dec 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A standard for-of loop would be more idiomatic and readable here: for (const node of nodes) { document.head.removeChild(node) }.
| for (let index = 0; index < nodes.length; index++) { | |
| document.head.removeChild(nodes[index]) | |
| for (const node of nodes) { | |
| document.head.removeChild(node); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Attempting to set
JSVideoPlugin = nullin local scope has no effect on the globalJSVideoPlugin. SinceJSVideoPluginis a global constructor, you should usewindow.JSVideoPlugin = nullinstead for proper cleanup.