Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 5 additions & 27 deletions plugins/domains/facebook.com/facebook.meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,21 @@ import * as entities from 'entities';

export default {

/**
* HEADS-UP: New endpoints as of Oct 24, 2020:
* https://developers.facebook.com/docs/plugins/oembed/
* Please configure your `access_token` in your local config file
* as desribed on https://github.com/itteco/iframely/issues/284.
*/

re: [
'facebook.post',
'facebook.video'
],

mixins: [
"domain-icon",
"oembed-author",
"oembed-canonical",
"oembed-site"
],

getMeta: function(oembed) {

if (oembed.html) {

var description = oembed.html.match(/<p>([^<>]+)<\/p>/i);
description = description ? description[1]: '';

var author = oembed.html.match(/Posted by <a(?:[^<>]+)>([^<>]+)<\/a>/);
author = author ? author[1]: oembed.author_name;

var title = oembed.html.match(/>([^<>]+)<\/a><p>/i);
title = title ? title[1] : author;

return {
title: title ? entities.decodeHTML(title) : oembed.title,
description: description ? entities.decodeHTML(description) : oembed.description,
author: author
};
getMeta: function(__allowFBThumbnail, meta) {
return {
title: meta.twitter?.title || meta.og?.title,
description: meta.twitter?.description || meta.og?.description,
canonical: meta.og?.url
}
},

Expand Down
39 changes: 4 additions & 35 deletions plugins/domains/instagram.com/instagram.com.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import cheerio from 'cheerio';

import { decodeHTML5 } from 'entities';

export default {

/**
Expand Down Expand Up @@ -29,37 +25,10 @@ export default {
provides: ['ipOG', '__allowInstagramMeta'],

getMeta: function (oembed, urlMatch, ipOG) {

var title = ipOG.title;
var description = ipOG.description || oembed.title;

if (!description || !title || /login/i.test(title)) {
var $container = cheerio('<div>');
try {
$container.html(decodeHTML5(oembed.html));
} catch (ex) {}

if (!title || /login/i.test(title)) {
var $a = $container.find(`p a[href*="${oembed.author_name}"], p a[href*="${urlMatch[1]}"]`);

if ($a.length == 1) {
title = $a.text();
title += /@/.test(title) ? '' : (oembed.author_name ? ` (@${oembed.author_name})` : '');
} else if (oembed.author_name) {
title = `Instagram (@${oembed.author_name})`;
}
}

if (!description) {
var $a = $container.find(`p a[href*="${urlMatch[1]}"]`);
description = $a.text();
}
}

return {
title: title,
description: description,
canonical: `https://www.instagram.com/p/${urlMatch[1]}`
title: ipOG.title,
description: ipOG.description,
canonical: ipOG.url || `https://www.instagram.com/p/${urlMatch[1]}`
}
},

Expand Down Expand Up @@ -90,7 +59,7 @@ export default {
// Remove below error when and if it's fixed. Validators will remove the link
og_image.error = 'Unfortunatelly Instagram\'s OG image is cropped';
} else if (!oembed.thumbnail_url) {
og_image.message = "Unfortunatelly, Instagram removed full images on October 1, 2025";
og_image.message = "Unfortunatelly, Instagram removed full images on November 3, 2025";
}
links.push(og_image);
}
Expand Down