Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***/ 909:
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.parseMetaTooltip = void 0;
- const parseMetaTooltip = (linksLength = 1) => {
- var _a, _b, _c;
- try {
- const selectors = {
- cover: [
- { selector: 'meta[property="twitter:image"]', attribute: 'content' },
- { selector: 'meta[property="og:image"]', attribute: 'content' },
- { selector: 'meta[itemprop="image"]', attribute: 'content' },
- { selector: 'meta[itemprop="image"]', attribute: 'content' }
- ],
- title: [
- { selector: 'meta[property="twitter:title"]', attribute: 'content' },
- { selector: 'meta[property="og:title"]', attribute: 'content' },
- { selector: 'meta[itemprop="name"]', attribute: 'content' },
- { selector: 'title', content: 1 },
- { selector: 'h1', content: 1 }
- ]
- };
- const resp = Object.entries(selectors).reduce((a, [name, selectors]) => {
- const current = selectors
- .map((e) => {
- const element = document.querySelector(e.selector);
- return (element &&
- ((e.attribute && element.getAttribute(e.attribute)) || (e.content && (element.textContent || '').trim())));
- })
- .filter((e) => e)[0];
- return { ...a, [name]: current };
- }, {});
- try {
- const YT_REGEXP = /^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/;
- if (YT_REGEXP.test(window.location.href)) {
- const id = (_a = window.location.href.match(YT_REGEXP)) === null || _a === void 0 ? void 0 : _a[1];
- resp.cover = `https://i.ytimg.com/vi/${id}/hqdefault.jpg`;
- resp.title = (_c = (_b = document.querySelector('h1')) === null || _b === void 0 ? void 0 : _b.textContent) === null || _c === void 0 ? void 0 : _c.trim();
- resp.url = `https://www.youtube.com/watch?v=${id}`;
- }
- }
- catch (e) { }
- resp.weight = 1 / linksLength;
- return resp;
- }
- catch (e) {
- console.error(e);
- return {};
- }
- };
- exports.parseMetaTooltip = parseMetaTooltip;
Advertisement
Add Comment
Please, Sign In to add comment