如何从Firefox扩展名捕获页面标题上的更改

编程入门 行业动态 更新时间:2024-10-11 21:28:27
本文介绍了如何从Firefox扩展名捕获页面标题上的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

解决方案

我不知道,如果它从Firefox扩展名起作用,但是在文档中可以使用,我认为它也可以从扩展名中使用。

您必须使用,特别是DOMSubtreeModified,www.w3/TR/DOM-Level-2-Events/events.html#Events-MutationEventrel =nofollow>。

一个小的示例脚本,放在< title />

< script type =text / javascript> <! - (function() { var _this = { target:document.getElementsByTagName('TITLE')[0], oldValue:document.title }; _this.onChange = function() { if(_this.oldValue!== document.title) { _this.oldValue = document.title; alert('somebody change the title'); } }; _this.delay = function() { setTimeout(_this.onChange,1); }; _this.target.addEventListener('DOMSubtreeModified',_ this.delay,false)})() // - > < / script>

Is there a way to capture when a website title changes from a firefox extension?

解决方案

I don't know, if it works from a firefox extension, but as it works in a document, I think it works from a extension too.

You have to work with Mutation-Events, especially DOMSubtreeModified. This fires on every change on the target.

A little example-script, put it somewhere after the <title/>

<script type="text/javascript"> <!-- (function() { var _this={ target:document.getElementsByTagName('TITLE')[0], oldValue:document.title }; _this.onChange=function() { if(_this.oldValue!==document.title) { _this.oldValue=document.title; alert('somebody changed the title'); } }; _this.delay=function() { setTimeout(_this.onChange,1); }; _this.target.addEventListener('DOMSubtreeModified',_this.delay,false) })() //--> </script>

更多推荐

如何从Firefox扩展名捕获页面标题上的更改

本文发布于:2023-11-05 18:11:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1561510.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:扩展名   页面   标题   Firefox

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!