Like chéo, cày rank 11/3

  • Người tạo chủ đề Người tạo chủ đề vitamin.d
  • Ngày bắt đầu Ngày bắt đầu
Trạng thái
Không mở để trả lời thêm.
Chạy code nào ae! :ah: :ah: :ah:
Mã:
(function(){
/* Tùy chọn reaction, các bạn thay các số tương ứng vào là được (vd: REACTION = 2)
     0 : Random
1 : Like
2 : Love
3 : Haha
4 : Wow
5 : Sad
6 : Angry
*/
const REACTION = 1;

/* Tùy chọn trang bắt đầu (khỏi phải scan lại từ đầu =]]) */
const START_PAGE = 1;

/* Tùy chọn like cho Top reaction (https://next.voz.vn/members/?key=highest_reaction_score.
    Set bằng 'true' nếu muốn like cho top.
Vì một voz tân có like bằng nhau
*/

const LIKE_HIGHEST_REACTION = true;
 
/*
    Like theo id người post (https://next.voz.vn/members/{id}/)
ex: const WHITE_LIST = ["id1", "id2", "id3", "id...N"]
*/
const WHITE_LIST = [];

/*
    Không Like theo id người post
ex: const BLACK_LIST = ["id1", "id2", "id3", "id...N"]
*/

const BLACK_LIST = [];

function getHttpRequest() {
  try {return new XMLHttpRequest();}
  catch (error) {}
  try {return new ActiveXObject("Msxml2.XMLHTTP");}
  catch (error) {}
  try {return new ActiveXObject("Microsoft.XMLHTTP");}
  catch (error) {}

  throw new Error("Could not create HTTP request object.");
}

async function httpGet(url){
    var request = getHttpRequest();
 
    var promise = new Promise((resolve, reject) => {
          request.onreadystatechange = function() {
             if (request.readyState==4 && request.status==200)
                {
                    resolve(request.responseText);
                }
          }
    });

    request.open("GET", url, true);
    request.send(null);

    return await promise;
}

async function httpPost(url, data){
    var request = getHttpRequest();
    var promise = new Promise((resolve, reject) => {
          request.onreadystatechange = function() {
             if (request.readyState==4 && request.status==200)
                {
                    resolve(request.responseText);
                }
          }
    });

    request.open("POST", url, true);
    request.setRequestHeader('Accept', 'application/json, text/javascript, */*; q=0.01');
    request.setRequestHeader('content-type', 'application/x-www-form-urlencoded; charset=UTF-8');
    request.send(data);

    return await promise;
}

function sleep (time) {
  return new Promise((resolve) => setTimeout(resolve, time));
}
/*------------------------------------------*/

function querySelectorAll(element, query){
    return Array.from(element.querySelectorAll(query));
}

async function getDocument(url){
    var text = await httpGet(url);
    var parser = new DOMParser();
 
    return parser.parseFromString(text, 'text/html');
}

async function getHighestReactionMembers(){
    var doc = await getDocument("/members/?key=highest_reaction_score");

    return querySelectorAll(doc, ".username").map(item=> /members\/(.*)\//gm.exec(item.href)[1]);
}

async function autoLike(reaction=1){
    var url = /(.*)\/(page)?/gm.exec(window.location.href)[1];
    var totalPage = 1;
    var pageNav = querySelectorAll(document, ".pageNav-page").pop();
    pageNav = pageNav ? pageNav.querySelector("a") : null;
 
    if(pageNav!=null){
        totalPage = /\/page-(.*)/gm.exec(pageNav.href)[1];
    }
    var pathName = /(.*)\/(page)?/gm.exec(window.location.pathname)+ "/";
 
    var highestReactionMembers = await getHighestReactionMembers();
 
    for(var i=START_PAGE;i<=totalPage;i++){
        console.log("-------- Like page: " + i + "--------");
        var htmlDoc = await getDocument(url+"/page-"+i);
        var token = htmlDoc.documentElement.getAttribute("data-csrf");
      
        querySelectorAll(htmlDoc, ".message.message--post").forEach(item=>{
            var postId = /js-post-(.*)/gm.exec(item.id)[1];
            var userId =  /members\/(.*)\//gm.exec(item.querySelector(".username").href)[1];
          
            if(WHITE_LIST!=null && WHITE_LIST.length > 0){
                if(WHITE_LIST.findIndex(item=>item==userId) == -1){
                    console.log("Ignore " + userId);
                    return;
                }
            }
          
            if(BLACK_LIST!=null && BLACK_LIST.length > 0){
                if(BLACK_LIST.findIndex(item=>item==userId) >= 0){
                    console.log("Ignore " + userId);
                  
                    return;
                }
            }
          
            if(!LIKE_HIGHEST_REACTION){
                if(highestReactionMembers.findIndex(item=>item==userId) >= 0){
                    console.log("Ignore " + userId);
                    return;
                }
            }
          
            if(item.querySelector("a.reaction.reaction--imageHidden")){
                 console.log("Like post: "+ postId);
                var r = reaction || Math.floor(Math.random() * 6)+1;
                httpPost("/posts/"+postId+"/react?reaction_id="+r, "_xfRequestUri="+pathName+"page-"+i+"&_xfWithData=1&_xfToken="+token+"&_xfResponseType=json");
            }
        });
      
        sleep(500);
    }
 
    console.log("done");
}

autoLike(REACTION);
})();
 
Trạng thái
Không mở để trả lời thêm.
/* VOZ — in-thread ad spread, client-side. * * Lives in the Siropu Ads Manager unit on `thread_view_below_messages` (the ad below the * last post), pasted after that unit's own and display() call. This file is the * source of truth; the ACP copy is a paste of it. Ads Manager's user/device/geo criteria * on that unit gate the whole thing. * * What it does: inserts up to `max` ad slots between posts, spaced by screen height rather * than post count. Anchors are post 1 and the first unread post (XF marks it `is-unread`; * it wins over post 1 when the two are closer than a gap) — each only if at least one gap * above the ad below the last post. Every stretch between anchors, and down to that bottom * ad, then gets as many slots as fit at the gap, spread evenly, each on the nearest post * boundary that keeps the gap, up to the cap — stretches below the unread post take their * share first (the reader scrolls down from there). Slot ids, gap, reserved size and backup * are per breakpoint (desktop / mobile). Slots are inserted as empty reserved boxes * (`voz-adSlot`, see extra.less) before PubPower fills them, so nothing shifts when an ad * arrives; the same markup gives them the backup, the hide-on-load and the fit rules. * * Re-runnable: window.vozThreadSpread() removes what it inserted and recomputes. */ (function () { var CONFIG = { max: 3, mobileMaxWidth: 650, label: 'Quảng cáo', // Per breakpoint: PubPower slot ids, one per placement in page order (kept per // device so each device's placements report under their own ids); the minimum // distance between ads (and from the last one to the bottom ad) as viewport heights, // or a string like '1200px'; the reserved size (voz-adSlot--… in extra.less); and the // backup shown until an ad has loaded. The backup keeps class voz-adSlot-backup // (hide-on-load, click-through when unfilled); --raw drops the style's own box so the // markup inside shows as written. desktop: { slots: ['pw_44325', 'pw_44329', 'pw_44331'], gap: 2, sizeClass: 'voz-adSlot--leaderboard', backupHtml: '' + '
AD · 970×90
' + '
' }, mobile: { slots: ['pw_44325', 'pw_44329', 'pw_44331'], gap: 3, sizeClass: 'voz-adSlot--rectangleLarge', backupHtml: '' + '
AD · 336×280
' + '
' } }; var MARK = 'data-voz-spread'; var script = document.currentScript; function pageTop(el) { return el.getBoundingClientRect().top + window.pageYOffset; } function pageBottom(el) { return el.getBoundingClientRect().bottom + window.pageYOffset; } function breakpoint() { return window.matchMedia('(max-width: ' + CONFIG.mobileMaxWidth + 'px)').matches ? CONFIG.mobile : CONFIG.desktop; } function gapPx() { var g = breakpoint().gap; return typeof g === 'string' ? parseFloat(g) : g * window.innerHeight; } function bottomAd() { var el = script; while (el && !(el.classList && el.classList.contains('voz-adSlot'))) el = el.previousElementSibling; return el; } function unit(slotId) { var bp = breakpoint(); var wrap = document.createElement('div'); wrap.className = 'voz-adUnit'; wrap.setAttribute(MARK, ''); wrap.innerHTML = (CONFIG.label ? '
' + CONFIG.label + '
' : '') + '
' + bp.backupHtml + '' + '
'; return wrap; } function run() { var old = document.querySelectorAll('[' + MARK + ']'); for (var k = 0; k < old.length; k++) old[k].parentNode.removeChild(old[k]); var posts = Array.prototype.slice.call(document.querySelectorAll('.block--messages article.message--post')); if (posts.length < 2) return []; var gap = gapPx(); var bottom = bottomAd(); var bottomY = bottom ? pageTop(bottom) : pageBottom(posts[posts.length - 1]); var chosen = []; function fits(y) { if (bottomY - y < gap) return false; for (var i = 0; i < chosen.length; i++) if (Math.abs(chosen[i].y - y) < gap) return false; return true; } function take(post) { var y = pageBottom(post); if (!fits(y)) return false; chosen.push({ post: post, y: y }); return true; } var unread = -1; for (var i = 0; i < posts.length; i++) if (posts[i].classList.contains('is-unread')) { unread = i; break; } // Anchors: the unread post (if a gap above the bottom ad), then post 1 (if a gap // from both). Every stretch between consecutive anchors and the bottom ad then gets // as many slots as fit at the gap, spread evenly, each on the nearest post boundary. if (unread >= 0) take(posts[unread]); take(posts[0]); chosen.sort(function (a, b) { return a.y - b.y; }); var uy = unread >= 0 ? pageBottom(posts[unread]) : -1; var bounds = chosen.map(function (c) { return c.y; }).concat([bottomY]); var segments = []; for (var s = 0; s + 1 < bounds.length; s++) segments.push({ a: bounds[s], b: bounds[s + 1] }); // Stretches below the unread post take their share of the cap first (the reader // scrolls down from there), then the ones above it, top-down. segments.sort(function (x, y) { return (x.a >= uy ? 0 : 1) - (y.a >= uy ? 0 : 1) || x.a - y.a; }); for (var t = 0; t < segments.length; t++) { var a = segments[t].a, b = segments[t].b; var n = Math.min(Math.floor((b - a) / gap) - 1, CONFIG.max - chosen.length); for (var j = 1; j <= n; j++) { var target = a + j * (b - a) / (n + 1), best = null, bestD = Infinity; for (var q = 0; q < posts.length; q++) { var yq = pageBottom(posts[q]); if (yq <= a || yq >= b || !fits(yq)) continue; var d = Math.abs(yq - target); if (d < bestD) { bestD = d; best = posts[q]; } } if (best) take(best); } } chosen.sort(function (a, b) { return a.y - b.y; }); window.powerTag = window.powerTag || {}; var placed = []; var slots = breakpoint().slots; for (var p = 0; p < chosen.length; p++) { var id = slots[p % slots.length]; chosen[p].post.insertAdjacentElement('afterend', unit(id)); placed.push({ afterPost: posts.indexOf(chosen[p].post) + 1, slot: id }); (function (slotId) { (window.powerTag.Init = window.powerTag.Init || []).push(function () { window.powerAPITag.display(slotId); }); })(id); } return placed; } window.vozThreadSpread = run; run(); })();

Thống kê chủ đề

Ngày tạo
vitamin.d,
Người trả lời cuối
chanvuong,
Trả lời
25.281
Lượt xem
466.204
Quay lại
Lên đầu trang