joplin-notes/joplin notion extension/Web Development/Javascript/Extensions/Tips.md
2026-11-04 00:33:23 +05:30

1.4 KiB

Tips

  • Bypass caching When injecting link element for css file, the problem of caching can be annoying so append something in the url like this
      // Create a link element for the CSS file
      const linkElement = document.createElement('link');
      linkElement.rel = 'stylesheet';
      linkElement.href = browser.runtime.getURL('styles.css') + '?v=' + Date.now(); // Append a timestamp
      document.head.appendChild(linkElement);
    
    
  • Reset injected element When we inject DOM element and reload extension previous one wont get removed unless page is reloaded so tag all those inserted element with extension name or by adding it in class. contentScript.js
    
      // removing elements of class of ext_name
      function reset1(){
    
       	const elements=document.querySelectorAll(`.${ext_name}`)
    
       	for(let ele of elements){
       		ele.remove()
       	}
    
    
       }
    
       reset1();
    
      const navibar= document.createElement("div")
      navibar.className=`${ext_name} navigation_bar`
      navibar.innerHTML=`
      	<button class=" nav_btn"> All Replies </button>
      `
    
    
      console.log('navibar: ',navibar.outerHTML);
    
    
    
      const app=document.querySelector("body")
      app.insertBefore(navibar, app.children[0])
    
    

 

in firefox to allow custom extensions for permanent without uploading in firefox

Type about:config in the address bar and press Enter Search for xpinstall.signatures.required. Ensure the value is set to false (toggle it by double-clicking if necessary).