ENforce

    @@ -4,6 +4,7 @@ * @include http://* * @include https://* * @contributor noromanba http://let.hatelabo.jp/noromanba/let/hLHVndmmiaF5 + * @contributor noromanba http://let.hatelabo.jp/noromanba/let/hLHVnvrnxfEx * @license MIT License https://opensource.org/licenses/MIT * @javascript_url */ @@ -12,6 +13,7 @@ // https://instagram.com/instagram // https://twitter.com/twitter // https://www.google.com +// https://webcache.googleusercontent.com/search?q=cache:https://example.com/ // TBD // - en-* en_* @@ -23,13 +25,13 @@ // intersection w/ loop implements c.f. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set#Implementing_basic_set_operations // TBD Map w/ hostname - const langQueue = new Set([ + const langQuery = new Set([ 'hl', 'lang', ]); // hard to intersection w/o loop - [...langQueue].some(key => { + [...langQuery].some(key => { if (url.searchParams.has(key)) { // TBD .get() instead url.searchParams.set(key, 'en'); return true;
  • /*
     * @title ENforce
     * @description enforce English page w/o login/sign-in
     * @include http://*
     * @include https://*
     * @contributor noromanba   http://let.hatelabo.jp/noromanba/let/hLHVndmmiaF5
     * @contributor noromanba   http://let.hatelabo.jp/noromanba/let/hLHVnvrnxfEx
     * @license     MIT License https://opensource.org/licenses/MIT
     * @javascript_url
     */
    
    // e.g.
    // https://instagram.com/instagram
    // https://twitter.com/twitter
    // https://www.google.com
    // https://webcache.googleusercontent.com/search?q=cache:https://example.com/
    
    // TBD
    // - en-* en_*
    // - pathname
    (() => {
        'use strict';
    
        const url = new URL(location.href);
        // intersection w/ loop implements c.f.
        // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set#Implementing_basic_set_operations
        // TBD Map w/ hostname
        const langQuery = new Set([
            'hl',
            'lang',
        ]);
    
        // hard to intersection w/o loop
        [...langQuery].some(key => {
            if (url.searchParams.has(key)) { // TBD .get() instead
                url.searchParams.set(key, 'en');
                return true;
            }
            // XXX redundant; order sensitive
            url.searchParams.append(key, 'en');
        });
    
        location.search = url.search;
    })();
    
    
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2018/08/02 07:48:33 - 2018-08-02
  2. 2018/07/31 08:50:38 - 2018-07-31
  3. 2018/07/31 08:48:47 - 2018-07-31