[?]ががっとリストに追加

    @@ -41,5 +41,5 @@ await fetch(t, Object.assign(a, { method: 'POST', body: JSON.stringify({ account_ids: l.map(i => i.id) }) - })).then(r => r.json()).then(j => console.log('リスト追加 : たぶん', typeof(j) == 'object')).catch(console.error); + })).then(r => r.json()).then(console.log).catch(console.error); })();
  • /*
     * @title [?]ががっとリストに追加
     * @description 特定のワードに引っかかる人をまとめてリストに追加します。追加したいリストを開いて実行してください。
     * @include *
     * @license MIT License
     * @javascript_url
     */
    
    // @include https://*/web/timelines/list/* くらい
    
    void (async (
     s = _ => new Promise(r => setTimeout(r, 2000)),
     m = JSON.parse(document.querySelector('#initial-state').textContent).meta,
     v = 'https://' + location.host + '/api/v1/',
     n = m ? v + 'accounts/' + m.me + '/following?limit=80' : 0,
     a = m ? { headers: {
      Authorization: 'Bearer ' + m.access_token,
      Accept: 'application/json',
      'Content-Type': 'application/json'
     } } : {},
     h = location.href.match(/web\/timelines\/list\/(\d+)/),
     t = h ? v + 'lists/' + h[1] + '/accounts' : 0,
     l = [],
     p = prompt('検索語', '@mstdn.maud.io')
    ) => {
    
    	while (n && t) {
    
    		await fetch(n, a).then(r => ((
    			n = (r.headers.has('Link') && (h = r.headers.get('Link').match(/<(.+?)>; rel="next"/))) ? h[1] : 0
    		), r.json())).then(j => (
    			l = l.concat(j.filter ? j.filter(i => JSON.stringify(i).includes(p)) : [])
    		));
    		console.log(l.length, n);
    		await s();
    
    	}
    
    	console.log(l.map(i => i.id));
    
    	await fetch(t, Object.assign(a, {
    	 method: 'POST',
    	 body: JSON.stringify({ account_ids: l.map(i => i.id) })
    	})).then(r => r.json()).then(console.log).catch(console.error);
    })();
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2019/02/11 09:28:19 - 2019-02-11
  2. 2018/02/07 11:19:11 - 2018-02-07
  3. 2018/02/07 11:16:22 - 2018-02-07
  4. 2018/02/07 11:16:07 - 2018-02-07