Skip to content

Commit

Permalink
domains: add Loom to public plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
iparamonau committed Jul 31, 2024
1 parent 7691eef commit 51fcb3f
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions plugins/domains/loom.com.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
export default {

re: /^https?:\/\/(?:www\.)?loom\.com\/share\//i,

mixins: ['*', 'domain-icon'],

getLink: function(iframe, query, twitter, options) {

if (!iframe.width || !iframe.height) {
return;
}

const width = twitter.player?.width || iframe.width;
const height = twitter.player?.height || iframe.height;

var hideinfo = options.getRequestOptions('loom.hideinfo',
!options.getProviderOptions('players.showinfo', true)
) || query._hideinfo === "true" || !!query._hideinfo;

if (hideinfo) {
query.hide_owner = true;
query.hide_share = true;
query.hide_title = true;
query.hideEmbedTopBar = true;
}

// Otherwise take only parameters from /embed redirect to /share....
// but clean them up when user requests via request option
var q = {};
if (options.getRequestOptions('loom.hideinfo') !== false) {
Object.keys(query).forEach(function(key) {
if (/^hide/.test(key)) {
q[key] = query[key];
if (!hideinfo) {
hideinfo = true;
}
}
});
}

return {
href: iframe.replaceQuerystring(q),
type: CONFIG.T.text_html, // Validator fails because we receive x-frame-options. It actually works fine.
rel: CONFIG.R.player,
'aspect-ratio': width / height,
options: {
hideinfo: {
value: hideinfo,
label: "Hide player attribution info"
}
}
}

},

tests: [
// redirects here with the query-string:
'https://www.loom.com/embed/e5b8c04bca094dd8a5507925ab887002?hide_owner=true&hide_share=true&hide_title=true&hideEmbedTopBar=true',
'https://www.loom.com/share/0808e55f94a24992b2de488ac56d3815?_hideinfo=true',
'https://www.loom.com/share/0808e55f94a24992b2de488ac56d3815',
'https://www.loom.com/share/7f68fa7f01e349cab91b0c36168f68c3'
]

};

0 comments on commit 51fcb3f

Please sign in to comment.