mirror of
https://bitbucket.org/skobkin/chrome_point_plus.git
synced 2024-11-13 22:33:05 +00:00
Встраивание Instagram из pull request #25.
This commit is contained in:
parent
afa1ef0fb0
commit
429c432dc5
|
@ -95,6 +95,12 @@
|
|||
"option_embedding_twitter_tweets": {
|
||||
"message": "Twitter"
|
||||
},
|
||||
"option_embedding_instagram_posts": {
|
||||
"message": "Instagram"
|
||||
},
|
||||
"option_embedding_instagram_posts_orig_link": {
|
||||
"message": "Leave original link"
|
||||
},
|
||||
"option_nsfw": {
|
||||
"message": "NSFW content filtering"
|
||||
},
|
||||
|
|
|
@ -95,6 +95,12 @@
|
|||
"option_embedding_twitter_tweets": {
|
||||
"message": "Twitter"
|
||||
},
|
||||
"option_embedding_instagram_posts": {
|
||||
"message": "Instagram"
|
||||
},
|
||||
"option_embedding_instagram_posts_orig_link": {
|
||||
"message": "Не убирать ссылку"
|
||||
},
|
||||
"option_nsfw": {
|
||||
"message": "Фильтрация NSFW-контента"
|
||||
},
|
||||
|
|
|
@ -28,12 +28,12 @@ div#markItUpText-input {
|
|||
}
|
||||
|
||||
/* Auto-loaded Booru pictures */
|
||||
.booru_pic {
|
||||
.booru_pic, .instagram-post-embedded {
|
||||
display: block !important;
|
||||
float: none !important;
|
||||
}
|
||||
|
||||
.booru_pic img {
|
||||
.booru_pic img, .instagram-post-embedded img {
|
||||
border: none;
|
||||
max-width: 60%;
|
||||
max-height: 300px;
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
/**
|
||||
* @deprecated since 1.36.0
|
||||
*/
|
||||
function $ajax_prot(settings){
|
||||
if (settings==undefined){return;}
|
||||
if (settings['url'] ==undefined){return;}this.url=settings['url'];
|
||||
|
@ -46,8 +49,14 @@ $ajax_prot.prototype={
|
|||
|
||||
$ajax=function (settings){return new $ajax_prot(settings);}
|
||||
|
||||
/**
|
||||
* @deprecated since 1.36.0
|
||||
*/
|
||||
function urlencode(text){return encodeURIComponent(text);}
|
||||
|
||||
/**
|
||||
* @deprecated since 1.36.0
|
||||
*/
|
||||
function sad_safe_reg(text){
|
||||
var ar='.-\\/[]{}?+';
|
||||
var s=''; for (var i=0;i<text.length;i++){
|
||||
|
@ -60,6 +69,9 @@ function sad_safe_reg(text){
|
|||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since 1.36.0
|
||||
*/
|
||||
function sad_xml_getnode(node,path){//node as domNode
|
||||
if ('' ==path){return node;}
|
||||
if ('#'==path){return node.textContent || node.text;}
|
||||
|
@ -81,6 +93,9 @@ function sad_xml_getnode(node,path){//node as domNode
|
|||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since 1.36.0
|
||||
*/
|
||||
function sad_xml_attribute(node,name){
|
||||
if (node==undefined){return undefined;}
|
||||
var r=new RegExp('^'+sad_safe_reg(name)+'$','i');
|
||||
|
@ -90,6 +105,9 @@ function sad_xml_attribute(node,name){
|
|||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since 1.36.0
|
||||
*/
|
||||
function sad_x2n(xml){
|
||||
return xml.responseXML.childNodes[xml.responseXML.childNodes.length-1];
|
||||
}
|
||||
|
|
|
@ -54,6 +54,11 @@ function PointPlus(ppVersion) {
|
|||
if (options.is('option_images_load_booru')) {
|
||||
load_all_booru_images();
|
||||
}
|
||||
|
||||
// Instagram
|
||||
if (options.is('option_embedding_instagram_posts')){
|
||||
instagram_posts_embedding_init(options);
|
||||
}
|
||||
|
||||
// Parse webm-links and create video instead
|
||||
if (options.is('option_videos_parse_links')) {
|
||||
|
@ -1548,3 +1553,50 @@ function twitter_tweet_embedding_parse_links() {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Instagram posts
|
||||
*
|
||||
* @param {OptionsManager} options OptionsManager with current options
|
||||
*/
|
||||
function instagram_posts_embedding_init(options) {
|
||||
var regex = new RegExp('^https?://(www\\.)?instagram\\.com/p/([\\w-]+)/?', 'i');
|
||||
|
||||
$('.post-content a').not('.booru_pic').each(function(num, $link) {
|
||||
var href = $link.href;
|
||||
var n;
|
||||
|
||||
if (n = href.match(regex)) {
|
||||
$ajax({
|
||||
'url': 'https://api.instagram.com/oembed?url=' + urlencode('http://instagram.com/p/' + n[2] + '/'),
|
||||
'success': function(text) {
|
||||
var answer = JSON.parse(text);
|
||||
var new_post = document.createElement('a');
|
||||
$(new_post).attr({
|
||||
'id': 'instagram-' + num,
|
||||
'href': answer.thumbnail_url,
|
||||
'title': answer.title,
|
||||
'target': '_blank',
|
||||
'data-fancybox-group': (options.is('option_fancybox_bind_images_to_one_flow'))
|
||||
? 'one_flow_gallery' : '',
|
||||
'data-fancybox-title': (options.is('option_fancybox_smart_hints'))
|
||||
? answer.title : ' '
|
||||
}).addClass('postimg instagram-post-embedded');
|
||||
|
||||
var image = document.createElement('img');
|
||||
image.alt = new_post.title;
|
||||
image.src = new_post.href;
|
||||
new_post.appendChild(image);
|
||||
|
||||
// Leave or replace
|
||||
if (options.is('option_embedding_instagram_posts_orig_link')) {
|
||||
$link.parentElement.insertBefore(new_post, $link);
|
||||
} else {
|
||||
$($link).replaceWith(new_post);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
"https://player.soundcloud.com/*",
|
||||
"https://api.kanaria.ru/point/*",
|
||||
"https://*.twitter.com/*",
|
||||
"https://api.instagram.com/*",
|
||||
"https://coub.com/embed/*",
|
||||
"storage",
|
||||
"notifications",
|
||||
|
|
|
@ -131,6 +131,16 @@
|
|||
<input type="checkbox" name="option-embedding-twitter-tweets">
|
||||
<span data-i18n="option_embedding_twitter_tweets"></span>
|
||||
</label>
|
||||
|
||||
<div class="option-node">
|
||||
<input type="checkbox" name="option-embedding-instagram-posts" id="option-embedding-instagram-posts">
|
||||
<label for="option-embedding-instagram-posts" data-i18n="option_embedding_instagram_posts"></label>
|
||||
|
||||
<label class="option-node">
|
||||
<input type="checkbox" name="option-embedding-instagram-posts-orig-link">
|
||||
<span data-i18n="option_embedding_instagram_posts_orig_link"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="option-node">
|
||||
|
|
Loading…
Reference in a new issue