Created
June 25, 2020 15:50
-
-
Save Harfho/ace237ada9a353a6c86dba9342a02a38 to your computer and use it in GitHub Desktop.
Load more post for you
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name chateko load posts | |
// @namespace http://tampermonkey.net/ | |
// @version 1.0 | |
// @description load more posts | |
// @author Harfho | |
// @match https://chateko.com/ | |
// @grant GM_setValue | |
// @grant GM_getValue | |
// @grant GM_setClipboard | |
// @grant unsafeWindow | |
// @grant window.close | |
// @grant window.focus | |
// @require http://code.jquery.com/jquery-3.4.1.min.js | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// Your code here... | |
var cont = true | |
// 1. Create the button | |
var button = document.createElement("button"); | |
button.innerHTML = "load posts"; | |
// 2. Append somewhere | |
var body = document.getElementsByTagName("body")[0]; | |
body.appendChild(button); | |
function loadposts(){ | |
var i=0 | |
var load = document.getElementById('load-more-posts') | |
button.innerHTML = 'Post' | |
for (i = 0; i < 5; i++) { | |
console.log('clicking',load) | |
load.click() | |
button.innerHTML = 'loaded' | |
} | |
cont = false | |
button.innerHTML = 'reload post' | |
} | |
// 3. Add event handler | |
button.addEventListener ("click", function(){ | |
console.log('startted') | |
if (cont){ | |
button.innerHTML = 'Post loading' | |
loadposts() | |
} | |
if (cont===false){ | |
cont=true | |
button.innerHTML = 'more posts' | |
} | |
}) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment