v

    @@ -12,10 +12,10 @@ // TBD simulate End key press -/* for mobile +/* for mobile and legacy browsers +javascript:window.scrollTo(0,Math.max.apply(null,[document.documentElement.scrollHeight,document.documentElement.clientHeight,document.body.scrollHeight,document.body.clientHeight])) javascript:window.scrollTo(0,Number.MAX_SAFE_INTEGER) javascript:window.scrollTo(0,Number.MAX_VALUE) -javascript:window.scrollTo(0,Math.max.apply(null,[document.documentElement.scrollHeight,document.documentElement.clientHeight,document.body.scrollHeight,document.body.clientHeight])) */ // avoid Magic Number e.g. @@ -43,13 +43,77 @@ // FIXME `Number.MAX_SAFE_INTEGER` methods do not working on Firefox 58.0.2 Desktop // expected scroll to bottom, but actual scroll to top; like this // window.scrollTo(0, 0) - // perhaps Fx treated like a "non-finite values", `NaN` and +/-`Infinity` c.f. + // perhaps Fx treated like a "finite values", `NaN` and +/-`Infinity` c.f. // https://www.w3.org/TR/cssom-view/#dom-window-scroll // https://www.w3.org/TR/cssom-view/#normalize-non-finite-values // https://www.w3.org/TR/cssom-view/#webidl-values // - // Firefox 58.0.2 mobile works well - // `Number.MAX_SAFE_INTEGER` and `Number.MAX_VALUE` methods + // scrollTo restricted from 32-bit limit? + // + // Firefox 58.0.2 mobile works fine + // `Number.MAX_SAFE_INTEGER`, `Number.MAX_VALUE` and `1e100` (!) //*/ })(); +// DBG +// window.scrollTo() w/ constants X-Browser +// +// - Chromium 64.0.3282.167 32-bit arch +// - Firefox 58.0.2 32-bit arch +// - Edge mobile 1.0.0.1656 Blink 64-bit arch +// - Firefox mobile 58.0.2 64-bit arch +// +// +// Browser Compatibility Table +// +// [x] works +// [ ] like a finite, treated to `0` +// [-] not check yet +// +// | Browser | height | MAX_SAFE_INTEGER | MAX_VALUE | exponential | hex | +// |--------------|--------|------------------|-----------|-------------|-----| +// | Chromium | [x] | [x] | [ ] | [ ] | [x] | +// | Firefox | [x] | [ ] | [ ] | [ ] | [x] | +// | Edge mobi | [x] | [x] | [ ] | [ ] | [-] | +// | Firefox mobi | [x] | [x] | [x] | [x] | [-] | +// +// exponential: 1e100 +// hex: 0xFFFFFFF (< signed 32-bit limit) +// +// +// IEEE 754[-2008] c.f. +// https://en.wikipedia.org/wiki/IEEE_754 +// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger +// +// Number.MAX_SAFE_INTEGER // 9007199254740991 +// Number.MAX_SAFE_INTEGER +// .toPrecision(16) // 9007199254740991 +// 2 ** 53 - 1 // 9007199254740991 +// Number.MAX_VALUE // 1.7976931348623157e+308 +// +// +// MAX_VALUE truncates +// +// bitwise op 32-bit signed number c.f. +// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Signed_32-bit_integers +// Math.pow(2, 32 -1) // 2147483648 +// +// Number.MAX_VALUE | 0 // 0 +// ~~Number.MAX_VALUE // 0 +// parseInt(Number.MAX_VALUE, 10) // 1 +// Math.trunc(Number.MAX_VALUE) // 1.7976931348623157e+308 +// +// +// Hex playing +// +// Number(0xFFFFFFFFFFFFFFFFF) // 295147905179352830000 +// Number(0xFFFFFFFFFFFFFFFFF0) // 4.722366482869645e+21 +// +// Chromium works +// window.scroll(0, '0x'.padEnd(Number.MAX_SAFE_INTEGER.toString().length, 'F')) +// +// Firefox works limit +// window.scrollTo(0, 0xFFFFFFF) // 268435455 +// 2 ** 32 - 1 // 2147483648 +// window.scrollTo(0, 0xFFFFFFF0) // 4294967280 +
  • /*
     * @title v
     * @description dumb jump to bottom of page; [Ctrl +] End alternatives
     * @include http://*
     * @include https://*
     * @license MIT License https://opensource.org/licenses/MIT
     * @javascript_url
     */
    
    // via
    // https://hail2u.net/blog/coding/window-scrollto-infinity-infinity.html
    
    // TBD simulate End key press
    
    /* for mobile and legacy browsers
    javascript:window.scrollTo(0,Math.max.apply(null,[document.documentElement.scrollHeight,document.documentElement.clientHeight,document.body.scrollHeight,document.body.clientHeight]))
    javascript:window.scrollTo(0,Number.MAX_SAFE_INTEGER)
    javascript:window.scrollTo(0,Number.MAX_VALUE)
    */
    
    // avoid Magic Number e.g.
    // 99999..., 10000... and 1e100...
    (() => {
        'use strict';
    
        //*/ boring...
        window.scrollTo(0, Math.max(...[
            document.documentElement.scrollHeight,
            document.documentElement.clientHeight,
            document.body.scrollHeight,
            document.body.clientHeight,
        ]));
        /*/
        window.scrollTo(0, Number.MAX_SAFE_INTEGER || Infinity);
        // XXX `Infinity` is fallback/workaround for IE (might be fixed) c.f.
        //     https://hail2u.net/blog/coding/window-scrollto-infinity-infinity.html
        //     https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER
        //
        //     You can use `Number.MAX_VALUE` BUT exponential;
        //     so hard to try decimalization before truncate c.f.
        //     https://stackoverflow.com/questions/18719775/parsing-and-converting-exponential-values-to-decimal-in-javascript
        //
        // FIXME `Number.MAX_SAFE_INTEGER` methods do not working on Firefox 58.0.2 Desktop
        //       expected scroll to bottom, but actual scroll to top; like this
        //            window.scrollTo(0, 0)
        //       perhaps Fx treated like a "finite values", `NaN` and +/-`Infinity` c.f.
        //       https://www.w3.org/TR/cssom-view/#dom-window-scroll
        //       https://www.w3.org/TR/cssom-view/#normalize-non-finite-values
        //       https://www.w3.org/TR/cssom-view/#webidl-values
        //
        //       scrollTo restricted from 32-bit limit?
        //
        //       Firefox 58.0.2 mobile works fine
        //       `Number.MAX_SAFE_INTEGER`, `Number.MAX_VALUE` and `1e100` (!)
        //*/
    })();
    
    // DBG
    // window.scrollTo() w/ constants X-Browser
    //
    // - Chromium         64.0.3282.167     32-bit arch
    // - Firefox          58.0.2            32-bit arch
    // - Edge mobile      1.0.0.1656 Blink  64-bit arch
    // - Firefox mobile   58.0.2            64-bit arch
    //
    //
    // Browser Compatibility Table
    //
    // [x] works
    // [ ] like a finite, treated to `0`
    // [-] not check yet
    //
    // | Browser      | height | MAX_SAFE_INTEGER | MAX_VALUE | exponential | hex |
    // |--------------|--------|------------------|-----------|-------------|-----|
    // | Chromium     | [x]    | [x]              | [ ]       | [ ]         | [x] |
    // | Firefox      | [x]    | [ ]              | [ ]       | [ ]         | [x] |
    // | Edge mobi    | [x]    | [x]              | [ ]       | [ ]         | [-] |
    // | Firefox mobi | [x]    | [x]              | [x]       | [x]         | [-] |
    //
    //  exponential: 1e100
    //  hex: 0xFFFFFFF  (< signed 32-bit limit)
    //
    //
    // IEEE 754[-2008] c.f.
    // https://en.wikipedia.org/wiki/IEEE_754
    // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger
    //
    // Number.MAX_SAFE_INTEGER          // 9007199254740991
    // Number.MAX_SAFE_INTEGER
    // .toPrecision(16)                 // 9007199254740991
    // 2 ** 53 - 1                      // 9007199254740991
    // Number.MAX_VALUE                 // 1.7976931348623157e+308
    //
    //
    // MAX_VALUE truncates
    //
    // bitwise op 32-bit signed number c.f.
    // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Signed_32-bit_integers
    // Math.pow(2, 32 -1)               // 2147483648
    //
    // Number.MAX_VALUE | 0             // 0
    // ~~Number.MAX_VALUE               // 0
    // parseInt(Number.MAX_VALUE, 10)   // 1
    // Math.trunc(Number.MAX_VALUE)     // 1.7976931348623157e+308
    //
    //
    // Hex playing
    //
    // Number(0xFFFFFFFFFFFFFFFFF)      // 295147905179352830000
    // Number(0xFFFFFFFFFFFFFFFFF0)     // 4.722366482869645e+21
    //
    // Chromium works
    // window.scroll(0, '0x'.padEnd(Number.MAX_SAFE_INTEGER.toString().length, 'F'))
    //
    // Firefox works limit
    // window.scrollTo(0, 0xFFFFFFF)    // 268435455
    // 2 ** 32 - 1                      // 2147483648
    // window.scrollTo(0, 0xFFFFFFF0)   // 4294967280
    
    
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2018/02/16 14:53:52 - 2018-02-16
  2. 2018/02/16 09:41:42 - 2018-02-16
  3. 2018/02/16 09:17:27 - 2018-02-16
  4. 2018/02/16 09:06:23 - 2018-02-16
  5. 2018/02/16 08:02:47 - 2018-02-16
  6. 2018/02/16 07:09:58 - 2018-02-16
  7. 2018/02/16 06:15:13 - 2018-02-16
  8. 2018/02/16 05:45:31 - 2018-02-16
  9. 2018/02/16 04:45:57 - 2018-02-16