Discussions » Development

Script CPU spike / page crash

§
Posted: 2016-08-20
Edited: 2016-08-22

Script CPU spike / page crash

Edit: After looking into the debugger (thanks, wOxxOm!), the issue was that clicking one of my inserted links was triggering some site script, causing that to bug out. I seem to have solved it by adding .on('click', function(e) {e.stopPropagation();}) to my links.

I've posted the script here: https://greasyfork.org/en/scripts/22529-lynda-com-downloads Hopefully, that's the end of its woes.

woxxomMod
§
Posted: 2016-08-20
Edited: 2016-08-20

In Tampermonkey you can add debugger; statement in the code, open devtools (F12 key), refresh the page and the debugger will pause the code so that you can step line by line or set breakpoints, inspect variables and so on.

$(the).attr('href')+' video:first'

You're adding a space and CSS selector to an URL, which doesn't make sense. Is it intended?

.one('click', downloads)

Shouldn't it be .on or you need a one-time listener?

$.when and .done

The docs say:

If a single argument is passed to jQuery.when() and it is not a Deferred or a Promise, it will be treated as a resolved Deferred and any doneCallbacks attached will be executed immediately. The doneCallbacks are passed the original argument. I

So you should use a typical function wrapper (callback) in .done

Post reply

Sign in to post a reply.