7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Macで閲覧中の全ページのMarkdownリンクをコピー (JXA)

Last updated at Posted at 2015-09-12
get_browser_markdown_links.scpt
function get_all_page_with_markdown_links(browser){
	if(browser == "Safari") {
		tab_title = "name"
	} else if (browser == "Chrome" || browser == "Google Chrome"){
		tab_title = "title"
	} else {
		throw "Unknown Browser: " + browser
	}

	all_tabs = Application(browser).windows.tabs()
	
	return all_tabs.map(function(tabs){
		return tabs.map(function(tab){
			url = tab.url()
			title = tab[tab_title]().replace(/[\[\]]/g,"\\$&").replace(/\\$/, "")
			
			return "- [" + title + "](" + url + ")"
		}).join("\n")
	}).join("\n\n")
}

// Markdown作成
safari_links = get_all_page_with_markdown_links("Safari")
chrome_links = get_all_page_with_markdown_links("Chrome")
all_links = safari_links + "\n\n" + chrome_links

// コピー
app = Application.currentApplication()
app.includeStandardAdditions = true
app.setTheClipboardTo(all_links)

SafariとChromeで開いている全ウィンドウをMarkdownリンクにしてコピーします。
ウィンドウ毎に2行改行します。
スクリプトメニューに置いて使います。

スクリーンショット 2015-09-13 17.09.40.png

※Filefoxをハブってるのは、SafariとChromeに比べてスクリプトの機能が貧弱貧弱ゥだからです。
Mac - JXAでSafari, Chrome, Firefoxを操作する際の違い - Qiita

追記:どう考えてもワンライナーよりスクリプトメニューに置いたほうが便利なのでワンライナーはやめました。


Qiita - Markdownのリンクを作成するブックマークレット - Qiita

7
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?