Created by
Idoenk . Heri Purnomo
| // ==UserScript==
// @name IG-Request
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://www.instagram.com/p/*
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.js
// @grant none
// ==/UserScript==
(function() {
'use strict';
function clog(x){console.log(x)}
clog($);
var params = {
"q": "ig_shortcode(BJIIHRrhl1Z)+%7B%0A++comments.before(%0A++++++++++++_____CURSOR_____%2C%0A++++++++++++20%0A++++++++++)+%7B%0A++++count%2C%0A++++nodes+%7B%0A++++++id%2C%0A++++++created_at%2C%0A++++++text%2C%0A++++++user+%7B%0A++++++++id%2C%0A++++++++profile_pic_url%2C%0A++++++++username%0A++++++%7D%0A++++%7D%2C%0A++++page_info%0A++%7D%0A%7D%0A",
"ref": "media::show"
},
sharedata = {},
url_a = "https://www.instagram.com/p/BJIIHRrhl1Z/?taken-by=9gag&__a=1",
url_query = "https://www.instagram.com/query/";
var query = function(cursor){
var params_ = {
"q": params.q,
"ref": params.ref
};
cursor = decodeURIComponent(cursor);
params_.q = unescape(params_.q);
params_.q = params_.q.replace(/\+/g, " ");
params_.q = params_.q.replace("_____CURSOR_____", cursor);
+function(){
$.ajax({
type: 'POST',
url: url_query,
data: params_,
headers: {
'x-csrftoken': $.cookie('csrftoken')
},
}).done(function(ret){
clog(ret);
if( ret && ret.comments && ret.comments.page_info && ret.comments.page_info.start_cursor )
$("#btn-next").attr('data-cursor', ret.comments.page_info.start_cursor);
});
}();
};
// 1st query start-cursor fetched from window._sharedData
setTimeout(function(){
sharedata = window._sharedData;
clog('sharedata:start_cursor='+sharedata.entry_data.PostPage[0].media.comments.page_info.start_cursor);
var foo = query(sharedata.entry_data.PostPage[0].media.comments.page_info.start_cursor);
}, 0);
// add element navigation
var $el = $('<button id="btn-next" class="_6snr4" data-cursor="" style="text-align:center;">Next</button>');
$el.click(function(){
var $me = $(this), cursor = $me.attr('data-cursor');
clog('inside click, cursor='+cursor);
query(cursor);
});
$el.prependTo($('[role=navigation]'));
})();
|