Giter Site home page Giter Site logo

erfanrajabi / external-extension Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ui3o/external-extension

0.0 0.0 0.0 102 KB

Chrome and Firefox extension for loading remote script from external repository (e.g. gitlab, github)

License: MIT License

JavaScript 82.39% Makefile 2.95% HTML 14.67%

external-extension's Introduction

Description

This plugin made for Chrome and Firefox. It is enable to load external script from external url.

Examples

  • example for load iframe in background
// load iframe in background
eex.loadBackgroundIframe({ id: 'foo', src: 'http://localhost:8099/'});
  • to receive background message possible to communicate through local storage
    • in every iframe will have window.eex object helper
    • work as usual with local storage in iframe and possible to sync local storage key with eex.saveStorageToParentStorage('foo')
    • these keys are auto synchronized on page load and possible to access with eex.getItem('localhost:8099', 'foo')
    • possible to listen these keys changes also with eex.regStorageItemChange('localhost:8099', 'foo', (val)=>{console.log('local store change: ', val)})
    • localhost:8099 is a domain which come from link option. It use host of link. See below.

Options

The injection settings need to be a JSON stringified array.

[{"link": "https://...js", "pathinclude": "/test/"}, {"link": "https://...", "pathinclude": "/test/", corsonly:true}, {"linkinclude": "https://...", "pathinclude": "/test/", corsonly:true}]

If corsonly is set, no external link will be loaded. The links just added only for CORS path, which means you can load resources from other url. Do not need to turn off the CORS in the browser! linkinclude also available only for CORS.

iframe

All iframe going to have a message listener:

window.addEventListener("message", (event) => {
    if (event.data.type === 'eexAppendScript' && event.data.script.length){
      ...
    }
  }, false);

You can insert script from top:

document.querySelectorAll('iframe').forEach(i=>{
  i.contentWindow.postMessage({type:'eexAppendScript', script:`console.log('foo')`}, '*');
})

License

MIT

external-extension's People

Contributors

ui3o avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.