11 2022 档案
摘要:使用replace(/[^0-9]/ig,"")将所有字符转换为空, 剩余只含数字的字符串, 然后再转换成数值类型就可以了,如下: let str = "jslfj560jasldf"; let newStr = +(str.replace(/[^0-9]/ig,"")); console.log(
阅读全文
摘要:注意使用chrome.tabs.onUpdated.addListener需要在manifest.json声明tabs权限 permissions: [‘tabs’] function handleUpdated(tabId, changeInfo, tabInfo) { console.log(`
阅读全文
摘要:I have used hash urls for my website and made safari extension for the same. For login/logout my extension opens ourdmain.in in new tab and listens to
阅读全文
摘要:Javascript 是异步的,一个常见的痛点是在页面上的 DOM 元素加载之前运行脚本。 处理此问题的一种方法是向文档中添加一个侦听器来侦听该DOMEContentLoaded事件。 document.addEventListener("DOMContentLoaded", function(){
阅读全文
摘要:Swap two nodes The function below swaps two given nodes, nodeA and nodeB: const swap = function (nodeA, nodeB) { const parentA = nodeA.parentNode; con
阅读全文