diff --git a/dist/core/index.js b/dist/core/index.js index 4c19e9d..383282a 100644 --- a/dist/core/index.js +++ b/dist/core/index.js @@ -3,10 +3,15 @@ var addScriptPromise = 0; /** Adds proviced script to the page, once **/ -function addPlatformScript(src) { +function addPlatformScript(src, scriptTagHook) { if (!addScriptPromise) { var s = document.createElement('script'); s.setAttribute('src', src); + + if (scriptTagHook) { + scriptTagHook(s); + } + document.body.appendChild(s); addScriptPromise = new Promise(function (resolve) { s.onload = function () { @@ -29,6 +34,9 @@ var defaultProps = { slug: { type: String }, + scriptTagHook: { + type: Function + }, options: Object /** Basic function used to mount Twitter component */ @@ -63,7 +71,7 @@ var twitterEmbedComponent = function twitterEmbedComponent(me) { params = this.id; } - Promise.resolve(window.twttr ? window.twttr : addPlatformScript('//platform.twitter.com/widgets.js')).then(function (twttr) { + Promise.resolve(window.twttr ? window.twttr : addPlatformScript('//platform.twitter.com/widgets.js', this.scriptTagHook)).then(function (twttr) { return me.embedComponent(twttr, params, _this.$el, _this.options); }).then(function (data) { _this.isAvailable = data !== undefined; diff --git a/readme.md b/readme.md index 04e0281..823ab6d 100644 --- a/readme.md +++ b/readme.md @@ -61,6 +61,25 @@ https://developer.twitter.com/en/docs/twitter-for-websites/embedded-tweets/guide Only `sourceType`: `profile`, `likes` and `list` are integrated. Embedded-Timeline Options Reference: https://dev.twitter.com/web/embedded-timelines/parameters +## Intercepting the `