Java script replacement

in Ideas and script requests
Subscribe to Java script replacement 6 posts, 3 voices



MrMgr User
FirefoxWindows

Hi,
I'm working on custom CRM in my company. It is used to collect and assign incoming tasks. We have only one person who is developing this c...

One of his idea is to automatically scroll the page to the bottom. It is incredibly annoying, I have to scroll the page back manually to top about 99% of the time.

He, will not remove this "feature".

I have identified file and part of java script responsible for this function.
I wish to replace this file:

http://XXXXXXXXXXXX.pl/js/main.func.js?v=2012-0...

with my own version in which this part of code is commented out:

//Form scrolling
var top_pos=0;
if ($("#popraw").length >0 )
{
$("#txt_opis_1").length >0 ? top_pos=$("#txt_opis_1").offset().top : top_pos = $("#popraw").offset().top;
}
else if($("#koniec").length >0 ) top_pos = $("#koniec").offset().top-($(window).height()/2);
$("html, body").animate({
scrollTop: top_pos}, 500);
//alert(top_pos);
//End of form scrolling

How to do this? Pleas help, my scrolling finger is so tired :(

 
devnull69 Scriptwright
FirefoxWindows

var $j = unsafeWindow.jQuery;
$j("html, body").scrollTop(0);

 
MrMgr User
FirefoxWindows

What i have to do with this code? I realy don't know how to start. I have created new script. It looks like

The config.xml
<userscriptconfig>
<include>http://XXXXXXXXXXXXXXXX.pl/*</include>
</userscriptconfig>

and script js:

// ==UserScript==
// @name Scroll Killer
// @namespace scrol_killer
// @include http://XXXXXXXXXX.pl/*
// @version 1
// ==/UserScript==

var $j = unsafeWindow.jQuery;
$j("html, body").scrollTop(0);

It scrolls to the bottom.

 
devnull69 Scriptwright
FirefoxWindows

Why would you change the config.xml?

Maybe try this:

window.addEventListener('load', function() {
   var $j = unsafeWindow.jQuery;
   $j("html, body").scrollTop(0);
}, false);

 
kuzu Scriptwright
FirefoxMacintosh

I have little knowledge of jQuery, but assuming the userscript runs during the scrolling animation, I think you need to first use $j("html, body").stop(); to cancel the animation before you try to set scrollTop. Otherwise the scrollTop value you set probably just gets immediately overwritten on the next step of the animation.

 
MrMgr User
FirefoxWindows

@devnull69
Thank you so much, it worked!