JSRUN 用代码说话
遍历狂魔
sunzehui
JSRUN的第30851位用户
加入于 2020-05-17
上次活跃 2020-08-07



function start(name){
  this.queue = Promise.resolve()
}

start.prototype.sleep = function(time){
  this.queue = this.queue.then(()=>{
    return new Promise((resolve)=>{
      setTimeout(()=>{
        console.log(`Sleep ${time}s`)
        resolve()
      },time*1000)
    })
  })
  return this
}
console.log(2)
s = new start()
s.sleep(5)
console.log(1)
sunzehui (遍历狂魔 )- 2020-08-06 0 人
js 延时
(function(){
  
  function hasClass(element, cls) {
      return (' ' + element.className + ' ').indexOf(' ' + cls + ' ') > -1;
  }



function start(name){
  this.queue = Promise.resolve()
}
//点红心
start.prototype.redLike = function(time){
  this.queue = this.queue.then(()=>{
    return new Promise((resolve,reject)=>{
      setTimeout(function(){

      let elem = document.querySelector(`#root > div > main > div > div.Club-container > div.Club-mainColumn > div > div.ClubPostList > div > section:nth-child(2) > div.PostItem-footer > div > div.css-2imjyh > div`)

      if (!hasClass(elem, "PostReactionItem-chosen")) {
          elem.click()
          console.log("点红心SUCCESS")
      }
      console.log("红心已被点击")
      resolve(1)
      },time*1000)
    })
  })
  return this
}

//评论
start.prototype.commentClick = function(time){
  this.queue = this.queue.then(()=>{
    return new Promise((resolve,reject)=>{
    setTimeout(()=>{


        document.querySelector(`#root > div > main > div > div.Club-container > div.Club-mainColumn > div > div.ClubPostList > div > section:nth-child(2) > div.PostItem-footer > div > button`).click()

    console.log("评论点击成功")
    resolve(1)
    },time*1000)

    })
  })
  return this
}


//点击展开
start.prototype.showAll = function(time){
  this.queue = this.queue.then(()=>{
    return new Promise((resolve,reject)=>{
    setTimeout(()=>{

            document.querySelectorAll(".CommentMoreReplyButton Button").forEach((res)=>{
            res.click()
            
        })
        console.log("点击展开")
        resolve(1)
        },time*1000)

    })
  })
  return this
}


//点击 赞
start.prototype.likeClick = function(time){
  this.queue = this.queue.then(()=>{
    return new Promise((resolve,reject)=>{
    setTimeout(()=>{

           
        document.querySelectorAll(".CommentItemV2-likeBtn").forEach((res)=>{
            res.click()
            
        })
        console.log("点击 赞")
        resolve(1)
        },time*1000)

    })
  })
  return this
}


//点击关闭
start.prototype.closeClik = function(time){
  this.queue = this.queue.then(()=>{
    return new Promise((resolve,reject)=>{
    setTimeout(()=>{
          document.querySelector(".Modal-closeButton").click()
          console.log("点击关闭")
          resolve(1)
        },time*1000)

    })
  })
  return this
}

start.prototype.delete = function(time){
  this.queue = this.queue.then(()=>{
    return new Promise((resolve,reject)=>{
    setTimeout(()=>{
      document.querySelector(`#root > div > main > div > div.Club-container > div.Club-mainColumn > div > div.ClubPostList > div > section:nth-child(2)`).remove()
            
      console.log("删除元素成功")
      if(document.querySelectorAll(`#root > div > main > div > div.Club-container > div.Club-mainColumn > div > div.ClubPostList > div > section`).length <=2 )
      {
        window.scrollTo(0, 200000000)
    
        console.log("元素数量不足滑动刷新")
      }
      resolve(1)
      },time*1000)

    })
  })
  return this
}

setInterval(()=>{

  s = new start()
  s.redLike(1)
  .commentClick(1)
  .showAll(5)
  .likeClick(2)
  .closeClik(2)
  .delete(2)

},15000)
})()
sunzehui (遍历狂魔 )- 2020-08-06 1 人
改进版点赞
sunzehui (遍历狂魔 )- 2020-08-04 0 人
知乎评论点赞

let data1=['PostReactionItem-chosen','11','12','PostReactionItem-chosen','11']

let newdata=data1.filter((res)=>{
    return !res.includes("PostReactionItem-chosen")
}).forEach(res=>console.log(res))

document.querySelectorAll(".PostReactionIcon").filter((res)=>{
    return !res.includes("PostReactionItem-chosen")
}).forEach(res=>res.click())


// console.log(newdata)

//程序运行完成时一定要有输出语句,本工具才能正确展示运行结果。 
console.log("Hello JSRUN!   \n\n         - from NodeJS .");
sunzehui (遍历狂魔 )- 2020-07-14 0 人
foreach和filter简单测试
#include <iostream>
using namespace std;
int main() {

    int myarr[10][3]={
        {5,5,5},//总行数 总列数 总数量
        {1,2,1},//第i行 第k列 值
        {2,2,33},//第i行 第k列 值
        {3,2,44},//第i行 第k列 值
        {4,5,3},//第i行 第k列 值
        {5,1,7}//第i行 第k列 值
    };

    for(int i = 0; i < 10 ; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            cout<<myarr[i][j]<<"  ";
        }
        cout<<endl;
    }
    cout<<"\n\n\n";
    for(int i=1 ;i<=myarr[0][0];i++)
    {
        for(int k=1 ;k<=myarr[0][1];k++)
        {
            if(myarr[i][0]==i&&myarr[i][1]==k)
            {
                cout<<myarr[i][2]<<" ";
            }
            else{
                cout<<0<<" ";
            }
        }
        cout<<endl;
    }

    //程序运行完成时一定要有输出语句,本工具才能正确展示运行结果。 
	cout << " " << endl;
	return 0;
}
sunzehui (遍历狂魔 )- 2020-07-10 0 人
C++实现稀疏数组
sunzehui (遍历狂魔 )- 2020-07-09 0 人
测试项目1
没有了
1/2 下一页