Scroll and prop

Scrolls fitocracy feed and gives props to everyone

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name      Scroll and prop
// @version   0.0.1
// @description Scrolls fitocracy feed and gives props to everyone
// @match     https://www.fitocracy.com/home/*
// @match     https://www.fitocracy.com/profile/*
// @namespace https://github.com/artm
// @require   https://cdnjs.cloudflare.com/ajax/libs/jquery-scrollTo/1.4.14/jquery.scrollTo.min.js
// @grant     none
// ==/UserScript==

createPropButton();

function createPropButton() {
  var button = $('<label for="autoprop">prop</label>')
  .appendTo('body')
  .css({position: "fixed"});
  
  $('<input id="autoprop" type="checkbox">')
  .appendTo('body')
  .button()
  .change(function(e) {
    if (this.checked) {
      scrollToUnpropped();
    } else {
      $(window)._scrollable().clearQueue().scrollTo("0%", 500);
    }
  });
  
  $(window)
  .resize(button, function(e) { keepCornered(e.data); })
  .resize();
}

function scrollToUnpropped(unpropped) {
  if (!unpropped || !unpropped.length) {
    unpropped = $(".stream_item .give_prop").get();
  }
  var topUnpropped = unpropped.shift();
  if (topUnpropped) {
    propAndContinue(topUnpropped, unpropped);
  } else {
    scrollForMore();
  }
}

function propAndContinue(topUnpropped, unpropped) {
  $(window)
  ._scrollable()
  .scrollTo(topUnpropped, 1000, {
    offset: -60
  })
  .delay(250)
  .queue(function() {
    $(this).dequeue();
    $(topUnpropped).click();
  })
  .delay(250)
  .queue(function() {
    $(this).dequeue();
    scrollToUnpropped(unpropped);
  });
}

function scrollForMore() {
  $(window)
  ._scrollable()
  .scrollTo("100%", 500)
  .delay(1000)
  .queue(function() {
    $(this).dequeue();
    scrollToUnpropped();
  });
}

function keepCornered(widget) {
  widget.position({ 
    my: "right bottom", 
    at: "right-10 bottom-10", 
    of: window, 
    collision: "none" 
  });
}