Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why it rescan elements exponentially? #86

Open
k-dmitrii opened this issue Dec 17, 2022 · 1 comment
Open

why it rescan elements exponentially? #86

k-dmitrii opened this issue Dec 17, 2022 · 1 comment

Comments

@k-dmitrii
Copy link

sorry, maybe it's newbie question, i'm not good at programming. i trying to write script for browser extension tampermonkey that filtering some elements and noticed that 'arrive' processed already existing elements
this page aliespress coupon center show 20 elements, when you scroll down it show another 20 and etc. (20, 40, 60, 80...) but 'arrive' processed exponentially:
20_40__60__80__100_120... <- elements on page
20_60_120_200_300_420... <- 'arrive' processed
so it sum up diagonally '/' (0+20=20, 20+40=60, 60+60=120, 120+80=200...)
tampermonkey simple script i used to check this

// ==UserScript==
// @name         New Userscript
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://campaign.aliexpress.com/wow/gcp/ae/channel/ae/accelerate/tupr*
// @require      https://cdnjs.cloudflare.com/ajax/libs/arrive/2.4.1/arrive.min.js
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @run-at       document-body
// ==/UserScript==

(function() {
    'use strict';

    let i=0;
    document.arrive('div[exp_type="coupon_exposure"]', function () {
        i++;
/*        if (isInteger(i/2)) {
            this.remove();
        }
*/
        if (isInteger(i/20)) {
            alert(document.querySelectorAll('div[exp_type="coupon_exposure"]').length + ' elements on page\n' + i + ' document.arrive processed');
        }
    });

function isInteger(num) {
  return (num ^ 0) === num;
}

})();

if remove some elements from page (commented 'this.remove'), like every 2nd, the sequence will remain 20_60_120_200_300_420...
is it normal or not? when i use filtering action in script it will do its actions again and again on the same elements :/

@matthew-dean
Copy link

That's concerning 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants