// ==UserScript== // @name newspicks_save_link // @description try to take over the world! // ==/UserScript== // ==UserScript== // @name newspicks_save_link // @namespace http://tampermonkey.net/ // @version 0.1 // @description try to take over the world! // @author You // @match https://newspicks.com/news/* // @grant none // ==/UserScript== var result = document.evaluate('//div[@class="meta-block clear"]', document, null, 7, null); result.snapshotItem(0).insertAdjacentHTML("beforeend", "
"); var result2 = document.evaluate('//div[@class="meta-block clear"]/div[last()]/a[1]', document, null, 7, null); result2.snapshotItem(0).addEventListener('click', sample, false); var result3 = document.evaluate('//div[@class="meta-block clear"]/div[last()]/a[2]', document, null, 7, null); result3.snapshotItem(0).addEventListener('click', sample2, false); var result4 = document.evaluate('//div[@class="meta-block clear"]/div[last()]/a[3]', document, null, 7, null); result4.snapshotItem(0).addEventListener('click', sample3, false); function sample() { var result5 = document.evaluate('//a[@class="read-more center"]', document, null, 7, null); var result6 = document.evaluate('//link[@rel="canonical"]', document, null, 7, null); for (var i = 0; i < 128; i++) { if (!("url" + (i + 1) in localStorage)) { if (i == 127) { alert("保存できるURLの数は128までに制限しています。\nローカルストレージから登録したキーを削除してください"); break; } else if (localStorage.getItem("url" + i) == result6.snapshotItem(0).href) { alert("このページは既に登録されています"); break; } localStorage.setItem("url" + (i + 1), result6.snapshotItem(0).href); localStorage.setItem(result6.snapshotItem(0).href, result5.snapshotItem(0).href); alert("「続きを読む」リンクのURLを保存しました"); break; } } } function sample2() { var buf = ""; var result6 = document.evaluate('//link[@rel="canonical"]', document, null, 7, null); for (var i = 0; i < 128; i++) { if ("url" + (i + 1) in localStorage) { var tmp = localStorage.getItem(result6.snapshotItem(0).href); buf = buf + " " + tmp; } else { break; } } var sign = prompt("url_list", buf); } function sample3() { var result6 = document.evaluate('//link[@rel="canonical"]', document, null, 7, null); if (result6.snapshotItem(0).href in localStorage) { localStorage.removeItem(result6.snapshotItem(0).href); alert("このページをキーから削除しました"); } else { alert("キーが登録されていません"); } }