pure Javascript implementation of some Chrome Console APIs
When I was writing bookmarklet I found that I can’t use those handy Chrome Console APIs like $, $$, copy, so I have to implement them myself.
$
This is similar to document.querySelector but $ supports the second optional parameter startNode (see here) but document.querySelector does not. Instead, we need to use element.querySelector (see here).
var $ = (selector, startNode) => (startNode || document).querySelector(selector);$$
This is similar to document.querySelectorAll.
One caviat is that the returned value is of type NodeList. It supports APIs like forEach but doesn’t support map as Array does. One way to get around it is to wrap it in Array.from.
var $$ = (selector, startNode) => Array.from((startNode || document).querySelectorAll(selector));copy
See my other post
说明
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是摆设,本站源码仅提供给会员学习使用!
7. 如遇到加密压缩包,请使用360解压,如遇到无法解压的请联系管理员
开心源码网 » pure Javascript implementation of some Chrome Console APIs
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是摆设,本站源码仅提供给会员学习使用!
7. 如遇到加密压缩包,请使用360解压,如遇到无法解压的请联系管理员
开心源码网 » pure Javascript implementation of some Chrome Console APIs