AO3 Review + Last Chapter Shortcut + Kudos-sortable Bookmarks

Adds shortcuts for last chapter and a floaty review box, sorts bookmarks by kudos (slow) and allows filter by complete only, download link to listing

< Spätná väzba na AO3 Review + Last Chapter Shortcut + Kudos-sortable Bookmarks

Hodnotenie: Dobré - skript funguje

§
Pridaný: 05.06.2021
Upravený: 05.06.2021

Floaty review Insert button stopped working in Firefox (89.0, using Tampermonkey). Developer Console gives the following error:

Uncaught TypeError: jQuery(...).getCursorPosition is not a function
    <anonymous> AO3 Review + Last Chapter Shortcut + Kudos-sortable Bookmarks.user.js:297
    jQuery 2
        dispatch
        handle
    nrWrapper 74765391:7
eval line 4 > eval:297:60
    <anonymous> AO3 Review + Last Chapter Shortcut + Kudos-sortable Bookmarks.user.js:297
    jQuery 2
    nrWrapper 74765391:7

I fiddled around with the code and this seems to have fixed it, though I'm not sure if it's the root of the problem as I don't really know javascript. Instead of defining the functions separately, like this...

(function (jQuery, undefined) {
    jQuery.fn.getCursorPosition = function() {
        /*more code*/
})(JQuery);

(function (jQuery, undefined) {
    jQuery.fn.selectRange = function(start, end) { 
        /*more code*/
})(JQuery);

//rest of the code

I stuck everything inside the anonymous function which is default when you create a Tampermonkey script:

/* eslint-env jquery */

(function() {
    jQuery.fn.getCursorPosition = function() { 
        /*function definition*/ 
    }

    jQuery.fn.getCursorPosition = function(start, end) { 
        /*function definition*/ 
    }

    //all the rest of the code 
})();

Let me say again that I have no idea what I'm actually doing; I'm just a monkey with access to google and a lot of free time. This works, but I've very little idea why.

Sorting by kudos still gives a syntax error.

§
Pridaný: 05.06.2021
Upravený: 05.06.2021

Addendum: apparently the problem is due to conflict with another script which also uses JQuery. When I disable this script, Insert works as expected. However, the fix(?) I posted lets both scripts work without issues.

Okay, uninstalled and reinstalled the script and now it works fine. idek.

Pridať odpoveď

Aby ste mohli pridať odpoveď, prihláste sa.

长期地址
遇到问题?请前往 GitHub 提 Issues。