<commit_before>// ==UserScript==
// @name        Reddit Auto Upvotes & Links
// @namespace   jBlue
// @description Upvotes all links and opens them in new tabs
// @include     https://www.reddit.com/*
// @version     1.0.2
// @grant       none
// ==/UserScript==

function getAllLinks() {
	var allVals = document.getElementById("siteTable").children;
	var newVals = [];
	for (var c = 0; c < allVals.length; c++){
		if (allVals[c].className != "clearleft" && allVals[c].className != "nav-buttons"){
			newVals.push(allVals[c]);
		}
	}
	return newVals;
}

function getLinksArray(lar, lchildren) {
	var linksFound = 0;
	for (var i = 0; i < lchildren.length; i++){
		var preLink = lchildren[i].children[4].children[3].children;
		var found = new Boolean(false);
		var foundNum = 0;
		while (found == false){
			if (foundNum == preLink.length){
				found = true;
			}else{
				if (preLink[foundNum].className === "first"){
					lar.push(preLink[foundNum].children[0].href);
					found = true;
				}else{
					foundNum++;
				}
			}
		}
	}
	return lar;
}

function upvotes(someArr) {
	for (var k = 0; k < someArr.length; k++){
		someArr[k].children[2].children[0].click();
	}
}

function newTabs(theL) {
	for (var l = 0; l < theL.length; l++){
		openNewBackgroundTab(theL[l]);
	}
}

function openNewBackgroundTab(tabLink){
    var a = document.createElement("a");
    a.href = tabLink;
    var evt = document.createEvent("MouseEvents");
    //the tenth parameter of initMouseEvent sets ctrl key
    evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0,
                                true, false, false, false, 0, null);
    a.dispatchEvent(evt);
}

function runner() {
	var allLinks = getAllLinks();
	var linkArray = [];
	var theLinks = getLinksArray(linkArray, allLinks);
	upvotes(allLinks);<commit_msg>add up function, edit upvotes<commit_after>// ==UserScript==
// @name        Reddit Auto Upvotes & Links
// @namespace   jBlue
// @description Upvotes all links and opens them in new tabs
// @include     https://www.reddit.com/*
// @version     1.0.3
// @grant       none
// ==/UserScript==

function getAllLinks() {
	var allVals = document.getElementById("siteTable").children;
	var newVals = [];
	for (var c = 0; c < allVals.length; c++){
		if (allVals[c].className != "clearleft" && allVals[c].className != "nav-buttons"){
			newVals.push(allVals[c]);
		}
	}
	return newVals;
}

function getLinksArray(lar, lchildren) {
	var linksFound = 0;
	for (var i = 0; i < lchildren.length; i++){
		var preLink = lchildren[i].children[4].children[3].children;
		var found = new Boolean(false);
		var foundNum = 0;
		while (found == false){
			if (foundNum == preLink.length){
				found = true;
			}else{
				if (preLink[foundNum].className === "first"){
					lar.push(preLink[foundNum].children[0].href);
					found = true;
				}else{
					foundNum++;
				}
			}
		}
	}
	return lar;
}

function upvotes(someArr) {
	for (var k = 0; k < someArr.length; k++){
		setTimeout(up, 1000, someArr[k].children[2].children[0]);
	}
}

function up(toBeClicked) {
	toBeClicked.click();
}

function newTabs(theL) {
	for (var l = 0; l < theL.length; l++){
		openNewBackgroundTab(theL[l]);
	}
}

function openNewBackgroundTab(tabLink){
    var a = document.createElement("a");
    a.href = tabLink;
    var evt = document.createEvent("MouseEvents");
    //the tenth parameter of initMouseEvent sets ctrl key
    evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0,
                                true, false, false, false, 0, null);
    a.dispatchEvent(evt);
}

function runner() {
	var allLinks = getAllLinks();
	var linkArray = [];
	var theLinks = getLinksArray(linkArray, allLinks);
	upvotes(allLinks);
{'fraction_non_alphanumeric': 0.1616216216216216, 'fraction_numerical': 0.011891891891891892, 'mean_word_length': 3.2736720554272516, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '211970', 'n_tokens_mistral': 1407, 'n_tokens_neox': 1290, 'n_words': 320}