|
|
|
Userscript index, For non-HV scripts |
|
May 27 2019, 02:42
|
Someguywith
Group: Gold Star Club
Posts: 7,427
Joined: 28-September 15
|
I didn't like that you can't bump a gallary with one button Current implementation is kinda hacky seeing as it just sets a value and then presses submit for you. I tried getting a html post to work but it kept changing my post data for some reason. **edit** Managed to find out why it wasn't working as I intended it. Combination of sending it as pain text instead of encoded and the fact that document.url was a string instead of a variable. Thanks to Shapes, Flarpa and Blue Penguin <3 CODE // ==UserScript== // @name Sort Bounties By Reward // @description Sort bounties by reward // @include https://e-hentai.org/bounty.php* // @exclude https://e-hentai.org/bounty.php?bid=* // @version 1.0 // @namespace SomeGuyWith, https://forums.ehentaihip.com/index.php?showuser=2725435 // ==/UserScript== (function() {
/*** Settings ***/ var hathToCredits = 4032 var credits = 5000 var hath = 0 /*** End of Settings ***/
var i = 0 var table = document.getElementsByClassName('itg'); var rows = table[0].rows; var main = document.getElementById('s'); var method = "POST"; var postData = "grant_cred=" + credits + "&grant_hath=" + hath + "&addreward=Submit+Additional+Reward"; var shouldBeAsync = true; var request = new XMLHttpRequest();
// fix css main.style.width = '1330px'; table[0].style.maxWidth = '99%';
for (let row of rows) { if (row === rows[0]) { var head = row.insertCell(5); head.innerHTML = 'Quick Bump' head.style.backgroundColor = '#E0DED3' head.style.fontWeight = 'bold'; head.style.padding = '3px 4px'; head.style.height = '16px'; } else { var cell = row.insertCell(5); var button = document.createElement('input'); cell.innerHTML = '<input type="button" name="addreward" value="QB (C: ' + credits + ' H: ' + hath + ')" id="quickBump" style="width: 130px; line-height: 10px; min-height: 10px; padding-top: 2px">'; cell.style.width = '135px'; cell.addEventListener( "click", onClick, false ); } }
const comparer = (idx, asc) => (a, b) => ((v1, v2) => v1 !== '' && v2 !== '' && !isNaN(v1) && !isNaN(v2) ? v1 - v2 : v1.toString().localeCompare(v2) )(getCellValue(asc ? a : b, idx), getCellValue(asc ? b : a, idx));
document.querySelectorAll('th').forEach(th => th.addEventListener('click', (() => { const table = th.closest('table'); Array.from(table.querySelectorAll('tr:nth-child(n+2)')) .sort(comparer(Array.from(th.parentNode.children).indexOf(th), this.asc = !this.asc)) .forEach(tr => table.appendChild(tr)); })));
function getNumerical(txt) { var credits = txt.match(/([0-9, ]+)Credits/i); var hath = txt.match(/([0-9, ]+)Hath/i); var reward = 0; if (credits) { credits = parseInt(credits[1].replace(/[, ]/g, '')) reward += credits } if (hath) { hath = parseInt(hath[1].replace(/[, ]/g, '')) reward += (hath * hathToCredits) } return reward }
const getCellValue = (tr, idx) => { if (idx === 4) { return getNumerical(tr.children[idx].innerText) } else { return tr.children[idx].innerText || tr.children[idx].textContent; } }
function onClick(elem) { console.log(elem.path[2].cells[1].children[0].href) request.open(method, elem.path[2].cells[1].children[0].href, shouldBeAsync); request.onreadystatechange = function() { if (request.readyState === 4) { window.location.reload(true); } }; request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); request.send(postData); } })();
This post has been edited by Someguywith: May 27 2019, 22:13
--------------------
|
|
|
|
|
|
May 27 2019, 22:06
|
Someguywith
Group: Gold Star Club
Posts: 7,427
Joined: 28-September 15
|
QUOTE(Someguywith @ May 22 2019, 20:10) I didn't like that you can't sort the bounties, so I fixed that. Can sort on date, name, type, status, reward and uploader
Code taken from Stack overflow/ an outdated reward sorter back from the g.e- days.
In the vein of my last script I added the same functionallity but then inside of the bounty list. CODE // ==UserScript== // @name Sort Bounties By Reward // @description Sort bounties by reward // @include https://e-hentai.org/bounty.php* // @exclude https://e-hentai.org/bounty.php?bid=* // @version 2.0 // @namespace SomeGuyWith, https://forums.ehentaihip.com/index.php?showuser=2725435 // ==/UserScript== (function() {
/*** Settings ***/ var hathToCredits = 4032 var credits = 5000 var hath = 0 /*** End of Settings ***/
var table = document.getElementsByClassName('itg'); var rows = table[0].rows; var main = document.getElementById('s'); var method = "POST"; var postData = "grant_cred=" + credits + "&grant_hath=" + hath + "&addreward=Submit+Additional+Reward"; var shouldBeAsync = true; var request = new XMLHttpRequest();
// fix css main.style.width = '1330px'; table[0].style.maxWidth = '99%';
for (let row of rows) { if (row === rows[0]) { var head = row.insertCell(5); head.innerHTML = 'Quick Bump' head.style.backgroundColor = '#E0DED3' head.style.fontWeight = 'bold'; head.style.padding = '3px 4px'; head.style.height = '16px'; } else { var cell = row.insertCell(5); var button = document.createElement('input'); cell.innerHTML = '<input type="button" name="addreward" value="QB (C: ' + credits + ' H: ' + hath + ')" id="quickBump" style="width: 130px; line-height: 10px; min-height: 10px; padding-top: 2px">'; cell.style.width = '135px'; cell.addEventListener( "click", onClick, false ); } }
const comparer = (idx, asc) => (a, b) => ((v1, v2) => v1 !== '' && v2 !== '' && !isNaN(v1) && !isNaN(v2) ? v1 - v2 : v1.toString().localeCompare(v2) )(getCellValue(asc ? a : b, idx), getCellValue(asc ? b : a, idx));
document.querySelectorAll('th').forEach(th => th.addEventListener('click', (() => { const table = th.closest('table'); Array.from(table.querySelectorAll('tr:nth-child(n+2)')) .sort(comparer(Array.from(th.parentNode.children).indexOf(th), this.asc = !this.asc)) .forEach(tr => table.appendChild(tr)); })));
function getNumerical(txt) { var credits = txt.match(/([0-9, ]+)Credits/i); var hath = txt.match(/([0-9, ]+)Hath/i); var reward = 0; if (credits) { credits = parseInt(credits[1].replace(/[, ]/g, '')) reward += credits } if (hath) { hath = parseInt(hath[1].replace(/[, ]/g, '')) reward += (hath * hathToCredits) } return reward }
const getCellValue = (tr, idx) => { if (idx === 4) { return getNumerical(tr.children[idx].innerText) } else { return tr.children[idx].innerText || tr.children[idx].textContent; } }
function onClick(elem) { console.log(elem.path[2].cells[1].children[0].href) request.open(method, elem.path[2].cells[1].children[0].href, shouldBeAsync); request.onreadystatechange = function() { if (request.readyState === 4) { window.location.reload(true); } }; request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); request.send(postData); } })();
This post has been edited by Someguywith: May 27 2019, 23:06
--------------------
|
|
|
|
|
|
May 28 2019, 16:37
|
nawrawrawr
Lurker
Group: Gold Star Club
Posts: 2
Joined: 6-June 10
|
QUOTE(Someguywith @ May 26 2019, 21:40) There's a high reason why it's listed as "never be added". If you want to sort every gallary you get you first need to get every gallary. Some tags have well over hunderd thousand gallaries attached to them. So you'd first need to request all thous gallaries, which is already a huge strain on the server. Then you'll need to sort them, sorting a small list is fine, but again. hunderd thousands of results is going to bring any machine to a grinding halt till it's done processing.
I definitely can see that issue now, thanks for thinking about it. I first imagined "Hey in case there are 2 or more pages, just make the script load all the pages in memory and sort from there" but... as you point out, one whoopie-search of a thousand pages and you're gonna hit the server hard - and your image limit. Yikes. QUOTE(Someguywith @ May 26 2019, 21:40) Something that is possible is to sort just one page of results, the issue is if the translated work is not on the same page it'll not be included next to the raw. But that would just defeat the purpose of what you'd want.
(That's atleast my asumption, if anyone who knows more sees this as wrong please feel free to correct me)
This would probably be the only sanitized solution to avoid the issue with the server being hit, but as you point out this would be a moot solution to [my] specific issue/request. I guess, if this ever gets to that stage, is to limit page depth to, say, 5 pages and then give it a global cooldown so it can't be abused to DoS the server. In fact every page-load should probably be delayed. If anyone needs need more pages they can donate to E-H for Perks to show more results per page. Although 200 * 5 is still a lot for the server to handle imo. Thinking about it, E-H is surprisingly robust despite the way Perks increase load on it. As much as I want this, it sounds more and more like a hassle... :} Thanks for your time, though!
|
|
|
|
|
|
Jul 25 2019, 17:18
|
blue penguin
Group: Global Mods
Posts: 10,025
Joined: 24-March 12
|
--------------------
QUOTE(blue penguin @ Jun 21 2021, 17:24) For 10 years of my life I have refused to add if-else blocks in order to support internet explorer idiocy, am not going to start doing it now in order to support google chrome's idiocy. Sorry folks. As harsh as the advice sounds my advice will be: use a browser that follows IETF standards.
|
|
|
|
|
|
Sep 24 2019, 22:23
|
blue penguin
Group: Global Mods
Posts: 10,025
Joined: 24-March 12
|
Script request /index.php?showtopic=232235One day i'll need to finally sort all this shit out (sorry)
--------------------
QUOTE(blue penguin @ Jun 21 2021, 17:24) For 10 years of my life I have refused to add if-else blocks in order to support internet explorer idiocy, am not going to start doing it now in order to support google chrome's idiocy. Sorry folks. As harsh as the advice sounds my advice will be: use a browser that follows IETF standards.
|
|
|
|
|
|
Sep 24 2019, 22:48
|
Mayriad
Group: Global Mods
Posts: 1,719
Joined: 18-December 10
|
QUOTE(blue penguin @ Sep 24 2019, 16:23) Script request /index.php?showtopic=232235One day i'll need to finally sort all this shit out (sorry) I have already completed this request. Edit: oh wait, you probably meant that you are going to add it to the index as a fulfilled request? I thought completed requests do not need to be added because the last request I completed was not added. This post has been edited by mayriad: Sep 29 2019, 21:02
--------------------
|
|
|
|
|
|
Oct 4 2019, 19:49
|
Markerov
Lurker
Group: Lurkers
Posts: 3
Joined: 20-September 12
|
"In order to combat spam, your first post can't contain any URLs" Hello, first time poster here! I encountered the aforementioned error message when trying to start a new thread for a script I wrote. Hopefully this one reply is enough for me to get my thread started. I'll update this post once I have a link. Edit: Here it is: Enhanced Keyboard NavigationThis post has been edited by Markerov: Oct 4 2019, 19:51
|
|
|
|
|
|
Oct 7 2019, 08:45
|
blue penguin
Group: Global Mods
Posts: 10,025
Joined: 24-March 12
|
QUOTE(Markerov @ Oct 4 2019, 12:49) That's some nice stuff, thanks. I wish violentmonkey (the one i use) would add GM_ aliases instead of using GM. for the grease monkey bindings. Making scripts portable is becoming a pain. (And yes, I will sort this thread out someday, sorry)
--------------------
QUOTE(blue penguin @ Jun 21 2021, 17:24) For 10 years of my life I have refused to add if-else blocks in order to support internet explorer idiocy, am not going to start doing it now in order to support google chrome's idiocy. Sorry folks. As harsh as the advice sounds my advice will be: use a browser that follows IETF standards.
|
|
|
|
|
|
Oct 7 2019, 13:05
|
Markerov
Lurker
Group: Lurkers
Posts: 3
Joined: 20-September 12
|
QUOTE(blue penguin @ Oct 7 2019, 08:45) I wish violentmonkey (the one i use) would add GM_ aliases instead of using GM. for the grease monkey bindings.
I'm not sure I understand, Violentmonkey use the GM_* style api. Or do you mean the other way round?
|
|
|
|
|
|
Oct 7 2019, 19:54
|
blue penguin
Group: Global Mods
Posts: 10,025
Joined: 24-March 12
|
QUOTE(Markerov @ Oct 7 2019, 06:05) I'm not sure I understand, Violentmonkey use the GM_* style api. Or do you mean the other way round? The other way around, yes. This is what I get by writing things at 4AM for me.
--------------------
QUOTE(blue penguin @ Jun 21 2021, 17:24) For 10 years of my life I have refused to add if-else blocks in order to support internet explorer idiocy, am not going to start doing it now in order to support google chrome's idiocy. Sorry folks. As harsh as the advice sounds my advice will be: use a browser that follows IETF standards.
|
|
|
|
|
|
Oct 21 2019, 23:37
|
aaaplus
Newcomer
Group: Recruits
Posts: 11
Joined: 30-November 12
|
a fix for general tag alias or just a cheap text replacer: (not my code, but copypasted post from page320 of the general tag thread) install this with ur usual javascript userscript manager: [ greasyfork.org] https://greasyfork.org/en/scripts/10976-rep...n-webpages/codeopen in any editor find CODE var words = {
put any replacements into any of the bracketed area after that, i.e. CODE 'yuri | lesbians' : 'yuri', and whatever else you can think of. change the @includes to restrict it to just /g/ pages don't know how efficient the code is I'll probably write a generic regex version soon of the delete everything after vertical bar | variety.
|
|
|
|
|
|
Oct 22 2019, 07:26
|
blue penguin
Group: Global Mods
Posts: 10,025
Joined: 24-March 12
|
QUOTE(aaaplus @ Oct 21 2019, 16:37) don't know how efficient the code is You're right. That thing is fucking naive, running regexes over the entire DOM is as slow as you get. QUOTE I'll probably write a generic regex version soon of the delete everything after vertical bar | variety. Give it a shot. I find this kind of script would be a good starter
--------------------
QUOTE(blue penguin @ Jun 21 2021, 17:24) For 10 years of my life I have refused to add if-else blocks in order to support internet explorer idiocy, am not going to start doing it now in order to support google chrome's idiocy. Sorry folks. As harsh as the advice sounds my advice will be: use a browser that follows IETF standards.
|
|
|
|
|
|
Dec 1 2019, 12:35
|
Elemhunter
Newcomer
Group: Members
Posts: 95
Joined: 30-March 11
|
Has there been any kind of script for gallery comment notifications? Even seeing a +1 next to a gallery would be useful. People think that they can ask questions in galleries you uploaded a year ago instead of messaging you.
--------------------
I very rarely check e-hentai's forum, shoot me an email at [email protected] or on Discord, Habanero#1239.
|
|
|
|
|
|
Dec 1 2019, 22:50
|
blue penguin
Group: Global Mods
Posts: 10,025
Joined: 24-March 12
|
QUOTE(Elemhunter @ Dec 1 2019, 04:35) Has there been any kind of script for gallery comment notifications? Even seeing a +1 next to a gallery would be useful. People think that they can ask questions in galleries you uploaded a year ago instead of messaging you.
Hhhmm. Reasonable for a script request, kind fo doable if one creates a "watch this gallery" button and keeps the data in local storage. Watching every gallery would bow your browser storage quite fast and probably ban you for too many requests. That said, if anyone wishes to take on such a script, let me go with a warning: comments are for the gallery not for flaming people. I can hardly see such a script being used for good purposes.
--------------------
QUOTE(blue penguin @ Jun 21 2021, 17:24) For 10 years of my life I have refused to add if-else blocks in order to support internet explorer idiocy, am not going to start doing it now in order to support google chrome's idiocy. Sorry folks. As harsh as the advice sounds my advice will be: use a browser that follows IETF standards.
|
|
|
|
|
|
Dec 5 2019, 02:23
|
Elemhunter
Newcomer
Group: Members
Posts: 95
Joined: 30-March 11
|
Ah, you might be right about the page requests part. What a hassle.
--------------------
I very rarely check e-hentai's forum, shoot me an email at [email protected] or on Discord, Habanero#1239.
|
|
|
|
|
|
Dec 9 2019, 12:33
|
ezdiy
Newcomer
Group: Recruits
Posts: 12
Joined: 10-May 19
|
CODE // ==UserScript== // @name EHMassTorrent // @namespace http://tampermonkey.net/ // @version 0.1 // @description try to take over the world! // @author You // @match https://e-hentai.org/?*f_search=* // @grant none // ==/UserScript==
(function() { var slack = 0.9; var seedtrump = 1.5; var minseeds = 2; 'use strict'; function gid(n) { return document.getElementById(n); } function gcls(n) { return document.getElementsByClassName(n); } function fget(n, def) { var v = gid(n).value || sessionStorage.getItem(n) || def; if (def !== undefined) { gid(n).value = v; } sessionStorage.setItem(n, v); return v; } function fset(n, v) { if (v === undefined) { v = fget(n); } gid(n).value = v; sessionStorage.setItem(n,v); } document.getElementById('dms').insertAdjacentHTML('afterbegin',` <table> <tr> <td>Next delay<td><input type=text id="nd" style="width: 30px;"></input> <td>Num pages<td><input type=text id="np" style="width: 30px;"></input> <td>Pos<td><input type=text id="pos" style="width: 30px;"></input>/<td id=pcnt></td> <td><button id="mstart">Start</button> <td id=stat> </table>`); fget('nd', 8000); fget('np', 0); fget('pos', 0); var isRunning = false; var startPos = 0; gid('mstart').addEventListener('click', function() { if (!isRunning) { startRunning(); } else { stopRunning(); } }); var children = gcls('gldown'); gid('pcnt').innerText = children.length; var stat = gid('stat'); var pos; var prev; function startRunning() { sessionStorage.setItem('forceStart', 0); pos = fget('pos', 0); function progress() { if (prev) { prev.style.backgroundColor = ''; } if (!isRunning) { return; } var dl = children[pos]; var np = fget('np')|0; // we're out. browse to next page, or stop if numpages goes to 0 if (np <= 0 || dl === undefined) { var newLoc = document.getElementsByClassName('ptt')[0].firstChild.firstChild.lastChild.firstChild.href; if (np <= 1 || !newLoc) { fset('np', 0); fset('pos', 0); stat.innerText = "No more pages requested, halted."; stopRunning(); return; } stat.innerText = "About to jump to next next page..."; setTimeout(function() { fset('np', np-1); fset('pos', 0); sessionStorage.setItem('forceStart', 1); document.location = newLoc; }, Math.random() * (fget('nd')|0) + (fget('nd')|0)); return; } var parent = dl.parentNode.parentNode; prev = parent; parent.style.backgroundColor = '#886'; var url = dl.firstChild.href; if (!url || localStorage.getItem(url)=="1") { console.log(url + " is already known or has no torrents; skipping"); pos++; fset('pos',pos); setTimeout(progress, 0); return; }
var iframe = document.createElement('iframe'); iframe.src = url; iframe.style.visibility = "hidden"; iframe.style.width = 0; iframe.style.height = 0; iframe.style.border = "0 none"; iframe.style.position = "absolute"; iframe.onload = function() { stat.innerText = "Loaded iframe, fetching torrent"; var forms = iframe.contentDocument.getElementsByTagName('form'); var tuples = []; var best = -1; var i; for (i = 0; i < forms.length-1; i++) { var td = forms[i].getElementsByTagName('td'); var dfunc = td[8].getElementsByTagName('a')[0].href; var seeds = td[3].innerText.split(':')[1].substr(1)|0; var size = eval(td[1].innerText.split(':')[1].replace('GB', '*1024*1024*1024').replace('MB', '*1024*1024').replace('KB','*1024').replace('B','')); tuples.push([dfunc,seeds,size]); // found larger torrent with some seeds if (seeds > minseeds && (best == -1 || size > tuples[best][2])) { best = i; } } var best2 = best; if (best != -1) { var bestt = tuples[best]; // now scan tuples again. if they're smaller by 'slack' (90%), but have more seeds 'seedtrump' (150%) of best torrent, choose that one instead for (i = 0; i < tuples.length; i++) { if (tuples[i][2] > bestt[2] * slack && tuples[i][1] > bestt[1] * seedtrump) { console.log("TRUMP",best2,"=>",i); best2 = i; } } // best2 is our final selection localStorage.setItem(url, "1"); console.log("Downloading " + url + " torrent index " + best2); var durl = tuples[best2][0]; document.location = durl; } document.body.removeChild(iframe); pos++; fset('pos',pos); setTimeout(progress, Math.random() * (fget('nd')|0) * 2 + 300); } stat.innerText = "Loading iframe for " + url; document.body.appendChild(iframe); }; isRunning = true; gid('mstart').innerText = "Stop"; progress(); } function stopRunning() { sessionStorage.getItem('forceStart', 0) isRunning = false; gid('mstart').innerText = "Start"; }
// Triggered by our forced 'next' click if (sessionStorage.getItem('forceStart')==1) { startRunning(); } })();
The workflow is: Specify narrow search query with stuff you want, then set numpages to something like 5 (5 * 25 = 125 torrents if you have 25 results per page). The script caches visited torrent download urls, so as to not hammer the server needlessly. The 8 seconds per torrent is reasonable value for gigabit home connection. If your torrenting is slow, you'll have to increase the step delay much higher (up to something like 50sec for typical cable). Otherwise you'll just bog down your torrent client. Browser must be set up to open torrent automatically and permit download of multiple files, and torrent client should auto-open likewise (qBT has such option for instance). This post has been edited by ezdiy: Dec 9 2019, 13:02
|
|
|
|
|
|
Dec 10 2019, 00:34
|
blue penguin
Group: Global Mods
Posts: 10,025
Joined: 24-March 12
|
^ Yep, that works.
I see that you are being careful and are adding an 8s delay between every pageload. A small delay between each page load was pretty much my only worry with a script that would get all torrents from a query.
Pretty neat work. I have added the script to the OP.
--------------------
QUOTE(blue penguin @ Jun 21 2021, 17:24) For 10 years of my life I have refused to add if-else blocks in order to support internet explorer idiocy, am not going to start doing it now in order to support google chrome's idiocy. Sorry folks. As harsh as the advice sounds my advice will be: use a browser that follows IETF standards.
|
|
|
Mar 3 2020, 16:26
|
EvaOtaku07
Group: Members
Posts: 2,254
Joined: 28-July 08
|
Are there any scripts that auto-redirect fjorded galleries?
-SNIP- but it's not working.
This post has been edited by blue penguin: Mar 4 2020, 00:22
|
|
|
Mar 4 2020, 00:22
|
blue penguin
Group: Global Mods
Posts: 10,025
Joined: 24-March 12
|
QUOTE(EvaOtaku07 @ Mar 3 2020, 08:26) Are there any scripts that auto-redirect fjorded galleries?
There are. But not here - for reasons
--------------------
QUOTE(blue penguin @ Jun 21 2021, 17:24) For 10 years of my life I have refused to add if-else blocks in order to support internet explorer idiocy, am not going to start doing it now in order to support google chrome's idiocy. Sorry folks. As harsh as the advice sounds my advice will be: use a browser that follows IETF standards.
|
|
|
Mar 4 2020, 07:35
|
EvaOtaku07
Group: Members
Posts: 2,254
Joined: 28-July 08
|
Dumb question to ask here I realize, sorry.
|
|
|
1 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
|
|
|
|
|