Welcome Guest ( Log In | Register )

291 Pages V « < 55 56 57 58 59 > »   
Reply to this topicStart new topic
> HV Script Thread, Discuss your creations. Includes guidelines and infos for script creation (2020-02-28 upd)

 
post Jan 28 2014, 00:34
Post #1121
ceawhadsf



Newcomer
**
Group: Members
Posts: 59
Joined: 28-March 13
Level 276 (Godslayer)


Build identifier: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0 (from about: page)
It is firefox 27 portable test. GreaseMonkey ver 1.14 and windows 7 64. i'm going to go through and update the plugins try different browser / version.
But my guess is the script isn't reading the HPMPSP values but i am not smart enough to figure out how to check for that.




CODE
var HPMPSP = document.getElementsByClassName('cwbt1');
var HP = HPMPSP[0].children[0].children[0].innerHTML.split('/');HP = parseFloat(HP[0])/parseFloat(HP[1]);
var MP = HPMPSP[1+(HPMPSP.length>3? 1: 0)].children[0].children[0].innerHTML.split('/');MP = parseFloat(MP[0])/parseFloat(MP[1]);
var SP = HPMPSP[2+(HPMPSP.length>3? 1: 0)].children[0].children[0].innerHTML.split('/');SP = parseFloat(SP[0])/parseFloat(SP[1]);

function gid(x){
    return document.getElementById(x);    
}
var Notalright =  HP<0.99||MP<0.99||SP<0.99;
if(Notalright){
    gid('monsterpane').setAttribute('style', 'border:2px solid #'+(111111 +8800*(SP<0.99 ? 1 : 0)+88*(MP<0.99 ? 1 : 0)+ 880000*(HP<0.99 ? 1 : 0))+ ';');
}

function CurrentMon(){
    var returnvalue = Math.round(1+(parseInt(document.defaultView.getComputedStyle(gid('ta_monster_1'), null)['top'])-29)/58-0.2);    
    
    if(returnvalue<1){    
    if(!(sessionStorage.CurrentMon)){
        return 'HOVERFIRST';
    } else return sessionStorage.CurrentMon;
        
    }
    sessionStorage.CurrentMon = 'mkey_'+(returnvalue % 10);
    return 'mkey_'+(returnvalue % 10);
}
function AmOverMonster() {
    return document.defaultView.getComputedStyle(gid('ta_monster_1'), null)['visibility'] == 'visible';
    }
function YEAH(HoverTurn) {
    if(document.querySelector('*:hover')==null||HoverTurn){
        if(HoverTurn&&(document.querySelector('div.btm1:hover')==null)){
        sessionStorage.lastActAttack=0;
        }
    } else if(!HoverTurn){
        var switchedMon=document.querySelector('div.btm1:hover');
        if(switchedMon==null){
        sessionStorage.lastActAttack=0;
        } else {
        sessionStorage.CurrentMon = switchedMon.getAttribute('id');
        sessionStorage.lastActAttack = 1;
        }
    }
var u = setTimeout(function(){YEAH(HoverTurn)},100);    
}
        
    
function HoverAttack(){
    var HoverAttacked = false;
    var HoveredControl = AmOverMonster();
    if(!Notalright)if(HoveredControl||(sessionStorage.lastActAttack==1)){
        var iXie = CurrentMon();
        if(iXie!='HOVERFIRST'){
        if(gid(iXie)){        
            if(gid(iXie).hasAttribute('onclick')){
                sessionStorage.lastActAttack = 1;
                YEAH(HoveredControl);
                gid(iXie).click();
                HoverAttacked=true;
                }
            }
        }
    }
if(!HoverAttacked){setTimeout(function(){HoverAttack()}, 100);}
}

function HB(HoverWhat){
    if(gid(HoverWhat))gid(HoverWhat).setAttribute('onmousemove','sessionStorage.lastActAttack=0;'+gid(HoverWhat).getAttribute('onclick'));
}
HB('ikey_p');

HoverAttack();
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Jan 28 2014, 01:04
Post #1122
Owyn



Casual Fapper
*****
Group: Members
Posts: 692
Joined: 12-May 10
Level 354 (Godslayer)


QUOTE
The question is, how do I turn this function into a clickable button? How would I insert it into this code (and would this code work!)?

See my fixed version of show gems script, it might help (IMG:[invalid] style_emoticons/default/happy.gif)
https://forums.e-hentai.org/index.php?showt...p;#entry3018231
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Jan 28 2014, 01:14
Post #1123
animeai



The Obsolete Hunter
*****
Group: Members
Posts: 620
Joined: 18-November 09
Level 333 (Godslayer)


XD Your link doesn't work - you must have a different number of posts per page or something. Found it with this though https://forums.e-hentai.org/index.php?s=&am...t&p=3018231

Looks like you're re-using the actual HV built in javascript - I did try that but must have typoed something >_> time for another try!
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Jan 28 2014, 02:02
Post #1124
Felipons



Newcomer
*
Group: Members
Posts: 40
Joined: 19-October 09
Level 428 (Dovahkiin)


Update for my script of my resize window script Last Version

New:
Now its working on Chrome
When you resize the window it automatically resizes dont need to do a postback
Correction of some bugs...


OLD 1.0.0 : Attached File  ChangePageStyle.User.zip ( 1.3k ) Number of downloads: 80

OLD 1.0.5 : Attached File  Change_Page_Style_1.0.5.User.zip ( 1.73k ) Number of downloads: 79


This post has been edited by Felipons: Dec 7 2021, 21:42
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Jan 28 2014, 02:38
Post #1125
Lement



Lalalala la~ la la~!
********
Group: Members
Posts: 2,977
Joined: 28-February 12
Level 326 (Godslayer)


@ceawhadsf: The same code you gave works fine in Firefox 25/Lubuntu 13, I immediatelly get a border upon casting HS. Quick search shows that Firefox 27(for devs) has some notable javascript reworking.

As for checking what it is parsing reading the HP value from, try writing,say,
CODE
alert("This is the HP element in HV: " + document.getElementsByClassName('cwbt1').children[0].children[0].innerHTML);
on 5th line. I assume mousemelee doesn't break down completely, which would be case if it didn't understand the code.

@animeai: What you're thinking of is better done by CSS - see the link "Pots" in my signature for an example. There are also native HV hotkeys for pots, infusions and scrolls in case you didn't know -F1-12 for pots, iirc +Shift for Scrolls and +Ctrl for Infusions(not that anybody uses infusions in battle).

Right-click for a menu is pretty rad idea though. Too bad I would never use it, though - way too slow.

This post has been edited by Lement: Jan 28 2014, 02:42
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Jan 29 2014, 14:28
Post #1126
Razor320



Casual Poster
***
Group: Members
Posts: 220
Joined: 17-October 13
Level 361 (Godslayer)


CODE
var HPMPSP = document.getElementsByClassName('cwbt1');
var HP = HPMPSP[0].children[0].children[0].innerHTML.split('/');HP = parseFloat(HP[0])/parseFloat(HP[1]);
var MP = HPMPSP[1+(HPMPSP.length>3? 1: 0)].children[0].children[0].innerHTML.split('/');MP = parseFloat(MP[0])/parseFloat(MP[1]);
var SP = HPMPSP[2+(HPMPSP.length>3? 1: 0)].children[0].children[0].innerHTML.split('/');SP = parseFloat(SP[0])/parseFloat(SP[1]);


This should be correct. Tested on Firefox.
CODE
var fields = document.getElementsByClassName("cwbt");
var stats = [];
for (var i = 0; i<3; i++){
    stats[i] = fields[i].textContent.split("/");
    stats[i] = parseInt(stats[i][0])/parseInt(stats[i][1]);
}
var HP = stats[0], MP = stats[1], SP = stats[2];

(Notice, that JavaScript doesn't have an integer variable type. For any number double precision float is used.)

CODE
var HoverAttacked = false;
...
if(!HoverAttacked){setTimeout(function(){HoverAttack()}, 100);}

'HoverAttacked' is unnecessary - setTimeout executes only once.

CODE
gid('monsterpane').setAttribute('style', 'border:2px solid #'+(111111 +8800*(SP<0.99 ? 1 : 0)+88*(MP<0.99 ? 1 : 0)+ 880000*(HP<0.99 ? 1 : 0))+ ';');

It is not necessary to use 'setAttribute' for standard attributes, like 'style' or 'className'.
Any integer can be transformed to string with 'toString()' or 'toString(radix)' methods. For example:
CODE
var b = 100;
var h = b.toString(16); //h now contains "64"


This post has been edited by Razor320: Jan 29 2014, 14:38
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Jan 29 2014, 15:23
Post #1127
Lement



Lalalala la~ la la~!
********
Group: Members
Posts: 2,977
Joined: 28-February 12
Level 326 (Godslayer)


QUOTE(holy_demon @ Jan 27 2014, 11:22) *

@Lement: I have a question about addEventListener. Which one would be more optimal in HV? Adding multiple event Listener to multiple elements, or just one eventListener to document.body and use event.target?

[stackoverflow.com] Stackoverflow has the answer and it says it's a trade-off between compile-time and run-time. In HV's context, what do we prefer?


As a rule, compile time is better than run-time for HV, because we want our scripts to load fast enough to be able to smoothly override HV hotkeys, especially with things like addEventListener, and also because we don't stay very long on any single page as opposed to most javascript more complex javascript usages you might encounter. But for you, in this case specifically? Run tests. Browsers can vary a lot.


Razor320: There are not always only 3 cwbt elements - if you're on low health, the flashing of it is done by layering another HP with different color on top of it and changing the opacity.

Also, setTimeout executes multiple times, not once, because it is inside HoverAttack(), thus executing itself - 10 times a second, in fact. HoverAttacked is to stop that once you attack so you don't have two loops executing at the same time 10 times per second. This sort of delay can be somewhat resource-intensive on slower computers or older browsers.

As for setAttribute, feel free to use plain .style when it works. I mostly did too, until I ran into some weird bug on working on this code, so I changed all to setAttribute.

As for the toString thing, you're missing that if you add together "111111", "8800" and "880000", you get "111111880088000" instead of 999911 if you used just numbers.

This post has been edited by Lement: Jan 29 2014, 15:23
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Jan 29 2014, 15:59
Post #1128
Owyn



Casual Fapper
*****
Group: Members
Posts: 692
Joined: 12-May 10
Level 354 (Godslayer)


QUOTE
As a rule, compile time is better than run-time for HV, because we want our scripts to load fast enough to be able to smoothly override HV hotkeys,

then why not run the script at @document-start?

setup time seems a huge problem on Chrome, and mostly not on Firefox for me.

*You''have to wait to check the health then though (mousemelee) (on hover maybe)

That could speed the things up probably.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Jan 29 2014, 18:05
Post #1129
Razor320



Casual Poster
***
Group: Members
Posts: 220
Joined: 17-October 13
Level 361 (Godslayer)


QUOTE
Razor320: There are not always only 3 cwbt elements - if you're on low health, the flashing of it is done by layering another HP with different color on top of it and changing the opacity.

Oh, in that case we can get parent elements (with 'cwbdv') and look at first 'cwbt' element.

Owyn, not all browsers support @run-at tag, and browsers which support it handle scripts differently. Generally, 'document-end' value means, that script is run exactly after html data is parsed and DOM is constructed for page (DOMContentLoaded event), when 'document-start' runs script before html loaded, so there isn't any node which can be used to set keyboard hooks other than 'window'.

Also, behavoir of Tampermonkey and Scriptish is different in this case - @run-at in Tampermonkey defines earliest moment at which script could be injected, while in Scriptish it is a hard directive for script injection. For example - if script takes too long to load, it could be executed after all content is loaded, even if it has '@run-at document-start'. Scriptish will delay loading of page, so until script finishes execution, page doesn't load further.

update
Modern JavaScript engines use JIT compilation. Tampermonkey and Scriptish cache scripts in browser's memory, so they will not recompile at each injection. Matter of setup time in case of great number of listeners or html modification is greatly overestimated. Insert a short shippet of code to look at loading times, and see yourself, that generally it takes less than few milliseconds to execute scripts. In my practice - 3-8 msec max for script ~40Kb size (code size, not data).

If anyone could describe, what you need from mousemelee, i can write it from scratch.

This post has been edited by Razor320: Jan 29 2014, 18:15
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Jan 29 2014, 19:12
Post #1130
Dan31



Chilling around
********
Group: Members
Posts: 4,399
Joined: 26-March 12
Level 485 (Godslayer)


Mousemelee Light 1.1: Hover cursor over monster to attack.
Attached File  hvmml.user.zip ( 464bytes ) Number of downloads: 473

A very small Mousemelee Light update to make the script more resilient to changes to the environment (by other scripts or a HV update).


Mousemelee Light+: Hover cursor over monster to attack. Stops on specified conditions.
Attached File  hvmmlp.user.zip ( 685bytes ) Number of downloads: 824

Introducing Mousemelee Light+! Like Lement's Mousemelee, you can now prevent hover attacks when hp/mp/sp are too low.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Jan 29 2014, 19:38
Post #1131
Lement



Lalalala la~ la la~!
********
Group: Members
Posts: 2,977
Joined: 28-February 12
Level 326 (Godslayer)


Razor320:

Also generates 4 of that. And 4 of that's parent. There's a reason why I check the length of HPMPSP for MP and SP. Furthermore, the cycle may be more "code" thing, but only really applies when one checks for HP, MP and SP. If it is any 2 of them or just 1 it is better to have individual lines, because, well, cycle for 2 elements seems kind of silly. Actually, even with 3 you're not saving any space or using less variables here.

And as for textContent, I initially used innerText -but that didn't work on firefox....Hence the uglier DoM climbing, which is a far older, more accepted standard.

@Compile time:

All saved lines speed up, each and every one of them do - hence why I uploaded MouseMeleeGenerator instead of having options like HVStat does. If you don't want to be stopped from attacking at low HP and leave the value to 0, the compiler will not include the line about HP.

You could perhaps make it smidge faster by checking HP after an attack has been made, perhaps, but it is naturally lot more risky.

As for keeping the compiled code in memory, I've heard that. And at least before the 4t/s limit, I could also visibly see the slowdown of HVStat even with all options turned off. I've tested stuff like having a just a single HV hotkey overriding in the start - can hold down and HV hotkey won't get called - and then that same hotkey overriding followed by giant if(false) statement - Oh hai focus there why am I dead - and can only conclude that no matter how it is kept, each line matters.

And that's why I created a script compilator instead of having bunch of variables for options at the top.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Jan 29 2014, 19:59
Post #1132
Razor320



Casual Poster
***
Group: Members
Posts: 220
Joined: 17-October 13
Level 361 (Godslayer)


Lement:
innerText is not in standard. textContent in. So far every major browser supports `textContent` (IE and Android browser also). Also, textContent should work faster or same as children[0].children[0], and you will be free from modifications in case developer adds or removes a layer of 'divs'.

Just checked and, no, additional text added in 'cwbdv' before normal node.
CODE

<div class="cwbdv">
    <img src="http://ehgt.org/v/s/barsilver.png" class="cwb2" style="width:41px" alt="health">
    <img src="http://ehgt.org/v/s/barfg.png" class="cwb3">
    <div class="cwbt" style="z-index: 10; opacity: 0.4;" id="healthflash">
        <div class="cwbt1">
            <div class="fd2" style="width:120px; height:16px">
                <div style="text-align:center; color:#CB000A; font-family:Trebuchet MS; font-size:10pt; font-weight:normal; font-style:normal; margin-top:-4px">
                    2335 / 6890
                </div>
            </div>
        </div>
    </div>
    <div class="cwbt">
        <div class="cwbt1">
            <div class="fd2" style="width:120px; height:16px">
                <div style="text-align:center; color:#FCFF00; font-family:Trebuchet MS; font-size:10pt; font-weight:normal; font-style:normal; margin-top:-4px">
                    2335 / 6890
                </div>
            </div>
         </div>
    </div>
</div>


Have you any measurements of actual execution speed of "parametrized" and "static" versions?

This post has been edited by Razor320: Jan 29 2014, 19:59
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Jan 29 2014, 21:16
Post #1133
holy_demon



Osananajimi<3
*********
Group: Gold Star Club
Posts: 5,417
Joined: 2-April 10
Level 500 (Godslayer)


QUOTE(Lement @ Jan 30 2014, 00:23) *

As a rule, compile time is better than run-time for HV, because we want our scripts to load fast enough to be able to smoothly override HV hotkeys, especially with things like addEventListener, and also because we don't stay very long on any single page as opposed to most javascript more complex javascript usages you might encounter. But for you, in this case specifically? Run tests. Browsers can vary a lot.


So I reckon, for HV, one signle window.addEventListener to handle all clicks/mousemove/etc... is more favorable than having like 10 eventListener for 10 elements
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Jan 29 2014, 22:22
Post #1134
Razor320



Casual Poster
***
Group: Members
Posts: 220
Joined: 17-October 13
Level 361 (Godslayer)


QUOTE(holy_demon @ Jan 29 2014, 21:16) *

So I reckon, for HV, one signle window.addEventListener to handle all clicks/mousemove/etc... is more favorable than having like 10 eventListener for 10 elements

For this count of listeners it won't make any difference, try yourself. Shorter code will make slight difference if JIT doesn't work for userJS. Not using event capturing will save some time though.

Lags of userJS in chrome is a matter of chrome itself. Use "@run-at document-start" and place code within listener of `DOMContentLoaded` event.
Don't inject code in page with <script> tags. Use event listeners and create events to trigger them, that would be also faster (at least in not triggering DOM refresh, it is funny, when in some scripts i see injecting at <body> - this trigger refresh on almost entire page - and then look at statements about execution speed), because js in a one-time injected <script> tag very likely will be executed in interpretation mode only.

PS. Users of Tampermonkey and Scriptish can use `unsafeWindow` internal object to obtain access to page javascript. So you can read credits value just using `unsafeWindow.current_credits`.

This post has been edited by Razor320: Jan 29 2014, 22:47
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Jan 30 2014, 04:46
Post #1135
Lement



Lalalala la~ la la~!
********
Group: Members
Posts: 2,977
Joined: 28-February 12
Level 326 (Godslayer)


@Razor320: Argh, you're right about cwbdv - I searched and found 4 of it, forgot about OC because it uses cwbt2 so it nearly never comes up.

As for textContent, if it is truly regular, might as well use it - tbh I used innerText because, well, chrome, and it'd seem obvious then that textContent would be for something not chrome. Making things easier to write is good. Speed, well that's what JSperf is for.

As for actual measurements of parametrized and static, I have not actually checked if having a number in three places is better than declaring a variable and using that instead of the number in those places. But for larger, parametrized version and static minimal, yes, I have tested it, and while my ping is a bit too small to properly run it by stopwatch/timer there is a reason why there is HVMA even if one can just turn the features in HVStat off - if(false){code} can still lag.

It's an interesting idea of using DOMContentLoaded in such way. Also, that is cool, useful tip about Tampermonkey/scriptish even if I won't be using it.

holy_demon: Well, if you're injecting the 10 elements, possibly in response to one another, one is indeed probably more favorable - DOM injection is not optimal.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Jan 30 2014, 19:40
Post #1136
Razor320



Casual Poster
***
Group: Members
Posts: 220
Joined: 17-October 13
Level 361 (Godslayer)


I have this idea for some time. How you think, if shop bot would be illegal? I mean, it is an automation, but not a gameplay automation, private trading between players don't seem to me like gameplay element.

Something like userJS script, that checks mail (forum mail or mogglemail) perodically for appropriate requests and serves them without player intervention. It also should be capable of maintaining actual list of items in form of post in forum thread.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Jan 30 2014, 21:47
Post #1137
Lement



Lalalala la~ la la~!
********
Group: Members
Posts: 2,977
Joined: 28-February 12
Level 326 (Godslayer)


Theoretically quite possible, I've been thinking of running a free shop with a helper script - I certianly wouldn't do it without human oversight, only checking stuff periodically.

There are though some troubles like a) multi-accounting due multiple IPs, (IMG:[invalid] style_emoticons/default/cool.gif) most people won't be able to have a computer running and c) anybody who would care enough to configure it would go through the effort of just checking HV periodically and using in-built user interface instead and d) the latter also means no fear of sending off your collection gear, for example.

As for legality, once you have something concrete, PM 10b as it is does not perform simple things.

This post has been edited by Lement: Jan 30 2014, 21:48
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Jan 31 2014, 15:12
Post #1138
Owyn



Casual Fapper
*****
Group: Members
Posts: 692
Joined: 12-May 10
Level 354 (Godslayer)



version 1.0 Attached File  fastest_mouse_melee.user.js.zip ( 1.06k ) Number of downloads: 58

version 1.1 Attached File  fastest_mouse_melee.user.js.zip ( 1.02k ) Number of downloads: 58


latest version https://forums.e-hentai.org/index.php?s=&am...t&p=3034527

Introducing Mousemelee Lightning+! Like Lement's or Dan31's Mousemelee :3

- 'Shift' hotkey to disable the script till you turn it back on or restart the browser *or launch the game in another window\tab (you can see when it's turned off in the Title)

- Show colored borders arounds monsters if low on hp\mp\sp (like in original MouseMelee) (works even when disabled)

= Works only for Firefox (sorry, Chrome can't handle its awesomeness)

Just was testing stuff and made this. It sets onhover attributes of monsters in the moment they appear and not later, did some measurments and this seem to show a bit better results than original mousmelle (might be better on faster computers)

my timings in ms between monster hits:
CODE
this: 276,267,269,244,255,245,250,257,267,322,325,284,269,276,274,279,255,327,282,272,287,275,268,270

original: 285,270,266,286,239,281,261,266,265,271,295,258,260,282,265,250,280,272,268,250,272,287,267,282


This post has been edited by Owyn: Jan 31 2014, 21:59
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Jan 31 2014, 15:15
Post #1139
Lement



Lalalala la~ la la~!
********
Group: Members
Posts: 2,977
Joined: 28-February 12
Level 326 (Godslayer)


Hm. About timings, if you can get 250ms between monster hits(what did you use, btw?) you're doing 4 turns/second and are capped.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Jan 31 2014, 15:42
Post #1140
Owyn



Casual Fapper
*****
Group: Members
Posts: 692
Joined: 12-May 10
Level 354 (Godslayer)


QUOTE
you're doing 4 turns/second and are capped.

what cap are you talking about?

I used simple js ( now - lasttime )
User is offlineProfile CardPM
Go to the top of the page
+Quote Post


291 Pages V « < 55 56 57 58 59 > » 
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 


Lo-Fi Version Time is now: 11th January 2025 - 14:39