1300

移行用のテストです

TwitterのTLで指定したユーザーの最新ツイートに移動

http://let.hatelabo.jp/jigendaddy/let/hJmd3o2kls49.js

// ==UserScript==
// @name         twitter_jump_user
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://twitter.com/*
// @grant        none
// ==/UserScript==
var result4=document.evaluate('//div[@class="follow-bar js-list-actions"]|//span[@class="DashboardProfileCard-screenname u-inlineBlock u-dir"]', document, null, 7, null);
result4.snapshotItem(0).insertAdjacentHTML("beforeend", "<input type='button' value='jump_user'>");
var result5=document.evaluate('//div[@class="follow-bar js-list-actions"]/input|//span[@class="DashboardProfileCard-screenname u-inlineBlock u-dir"]/input', document, null, 7, null);
result5.snapshotItem(0).addEventListener('click', sample, false);

function sample() {
  var sign = window.prompt("誰のツイートに飛びますか", "アカウント名の@以下を入力してください");
  var result = document.evaluate('//div[@class="stream-item-header"]/descendant::span[contains(@class,"username")][1]/b/text()', document, null, 7, null);
  var result2 = document.evaluate('//div[@class="stream-item-header"]/descendant::span[contains(@class,"username")][1]', document, null, 7, null);
  var flag = 0;
  for (var i = 0; i < result.snapshotLength; i++) {
    if (result.snapshotItem(i).nodeValue == sign) {
      result2.snapshotItem(i).id = "hoge";
      flag = 1;
      break;
    }
  }
  if (flag == 1) {
    var result3 = document.evaluate('id("hoge")/ancestor::li[1]', document, null, 7, null);
    //location.href=location.href.repalce(location.hash,"")+"#"+result3.snapshotItem(0).id;
    var l_url = location.href;
    l_url = l_url.replace(location.hash, "");
    location.href = l_url + "#" + result3.snapshotItem(0).id;
  } else {
    alert("該当するユーザーのツイートがありません");
  }
}