Menu

Skip to content
AppleScriptの穴
  • Home
  • Products
  • Books
  • Docs
  • Events
  • Forum
  • About This Blog
  • License
  • 仕事依頼

AppleScriptの穴

Useful & Practical AppleScript archive. Click '★Click Here to Open This Script' Link to download each AppleScript

月: 2019年9月

display youtube Script Libraryをアップデート

Posted on 9月 7, 2019 by Takaaki Naganoya

一発芸、出落ちと呼ばれた「display youtube」Script libraryをアップデート(v2.0)しました。

Download display youtube_v2.scptd (To ~/Library/Script Libraries/)

アップデート内容:
・AppleScript用語辞書内にサンプルScript(すぐに使えるScriptリンク内蔵)を掲載した
・start fromオプションを新設。再生開始位置を秒数で指定できるようにした
・エラーメッセージ内容をより親切にした

利用条件:
・YouTubeのムービーを視聴可能な程度のインターネット接続回線に接続していること
・macOS 10.11以降。実際の確認はmacOS 10.12以降。未確認ながら10.10上でも動作するはず

display youtubeライブラリの用語辞書を読むには、スクリプトエディタ上で、


▲「ウィンドウ」から「ライブラリ」を実行


▲「ライブラリ」パレットに「display youtube」ライブラリファイルをドラッグ&ドロップ。このライブラリパレット上のdisplay youtubeをダブルクリックすると用語辞書が表示されます


▲starts from無指定時(冒頭から再生)


▲starts from 24(冒頭から24秒の箇所から再生)


▲starts from 290(冒頭から290秒の箇所から再生)

YouTube上のオンラインゲームのリプレイムービーを視聴するような場合には、ムービー内容のうちスキップしたい場所とか「ここだけ見たい」という箇所は固定で決まっています(プログラムから書き出してYouTubeにアップロードするため)。そこで、再生開始ポジションを明示的に指定できると便利かと思われました。

ほかにも、いろいろと追加すると便利そうな機能はあります(未実装)。

いくつかボタンをダイアログ上に追加表示して、指定の秒数の箇所に頭出しするとか、表示内容のキャプチャーを撮るとかです(WkWebViewの表示内容を画像としてキャプチャする方法がぜんぜん不明。ウィンドウごとPDFとしてキャプチャしても撮れないし)。

コンピュータにスマホの機能で満足してしまうユーザーが多い昨今、ダイアログという箱庭的なUser Interface上にちょっとした便利機能を表示して使えるようにすると、それなりに満足できるユーザーが多いのではないかという仮説のもとに作成してみましたが、どんなもんでしょうか。

ちなみに、このリプレイムービーで自分はジオンの2番機でザクキャノンに搭乗。拠点を叩きつつ僚機にチャットで指示を送って、チームワークの力で勝利しました。

AppleScript名:display youtube sample
—
–  Created by: Takaaki Naganoya
–  Created on: 2019/08/25
—
–  Copyright © 2019 jp.piyomarusoft, All Rights Reserved
—
use AppleScript version "2.5" — El Capitan (10.11) or later
use framework "Foundation"
use scripting additions
use utbLib : script "display youtube"

set aURL to "https://www.youtube.com/watch?v=GP_tVXTYdmY"
display youtube main message "Replay Movie" sub message "My Senjo No Kizuna replay movie on YouTube" with URL aURL with size {900, 600} starts from 24

★Click Here to Open This Script 

Posted in Network Script Libraries sdef URL | 1 Comment

2つのレコードのキーの重複を計算

Posted on 9月 7, 2019 by Takaaki Naganoya

2つのレコードのキーの重複を検出するAppleScriptです。

こういう処理がお手軽にできるようになったので、macOS 10.10以降のAppleScriptでないとプログラムが組めなくなっている今日このごろ。死ぬほど努力してOld Style AppleScript(Cocoaの機能を使わない)だけで組めないこともないですが、それだけで半日は費やして数百行のプログラムになってしまいそうです。

というわけで、Cocoaの機能を利用した「ありもの」のルーチンを組み合わせるだけでほぼ完成。2つのレコードのキーの重複計算を行います。

どういう用途で使うかといえば、パラメータつきのURLに対して追加パラメータを付加したい場合です。URLからレコード形式でパラメータを分離し、追加パラメータ(レコード形式)を足し算する「前」に、2つのレコード間で重複キーがないかチェックする、という用途です。

では、2つのレコードの加算はどーするのか? という話になりますが、それは単に&演算子で加算するだけです。

set aRec to {abc:"1", bcd:"2"}
set bRec to {ccc:"0", ddd:"9"}
set cRec to aRec & bRec
–> {abc:"1", bcd:"2", ccc:"0", ddd:"9"}

★Click Here to Open This Script 

AppleScript名:2つのレコードのキーの重複を計算.scptd
—
–  Created by: Takaaki Naganoya
–  Created on: 2019/09/06
—
–  Copyright © 2019 jp.piyomarusoft, All Rights Reserved
—
use AppleScript version "2.4" — Yosemite (10.10) or later
use framework "Foundation"
use scripting additions

property NSSet : a reference to current application’s NSSet
property NSCountedSet : a reference to current application’s NSCountedSet
property NSMutableDictionary : a reference to current application’s NSMutableDictionary

set aRec to {autoplay:"1", hd:"9"}
set bRec to {v:"GP_tVXTYdmY", t:"120", hd:"3"}

set dupKeys to detectDuplicateKeysInTwoRecords(aRec, bRec) of me
–> {"hd"}

on detectDuplicateKeysInTwoRecords(aRec, bRec)
  set aDict to NSMutableDictionary’s dictionaryWithDictionary:aRec
  
set bDict to NSMutableDictionary’s dictionaryWithDictionary:bRec
  
  
set aKeyList to (aDict’s allKeys()) as list
  
set bKeyList to (bDict’s allKeys()) as list
  
  
set allKeyList to aKeyList & bKeyList
  
  
set aRes to returnDuplicatesOnly(allKeyList) of me
  
return aRes
end detectDuplicateKeysInTwoRecords

–1D Listから重複項目のみ返す
on returnDuplicatesOnly(aList as list)
  set aSet to NSCountedSet’s alloc()’s initWithArray:aList
  
set bList to (aSet’s allObjects()) as list
  
  
set dupList to {}
  
repeat with i in bList
    set aRes to (aSet’s countForObject:i)
    
if aRes > 1 then
      set the end of dupList to (contents of i)
    end if
  end repeat
  
  
return dupList
end returnDuplicatesOnly

★Click Here to Open This Script 

Posted in list Record | Tagged 10.12savvy 10.13savvy 10.14savvy NSCountedSet NSMutableDictionary NSSet | Leave a comment

指定URLのMS名を取得する v2b

Posted on 9月 4, 2019 by Takaaki Naganoya

edama2さんから投稿していただいた、指定URLの初出の指定タグ要素を抽出するAppleScriptです。

戦場の絆Wiki上の指定ページ上の指定タグでマークされたテキストを取得します。

ブログを見ていて思いつき、前に作りかけていたのを清書して送ります。

名前は「指定URLのMS名を取得するv2b」です。
内容はWKWebviewでページを読み込んで、javascriptで要素を取得しています。
前の二つよりスマートではありませんが、こんなやり方もあるってことで...

色々書き換えているうちに元がないですが、元ネタはapplescriptの穴からです。

プログラムも短いわけではなく、処理速度も速いわけでもなく(自分の環境で9秒ぐらい)、ただ見ただけだと「????」という内容ですが、本プログラムの価値は処理対象ではなく、

AppleScriptからWkWebViewに対して任意のJavaScriptを実行して処理しているサンプルである

という1点に尽きます。これはー、セキュリティ上のしばりがきつくて、けっこう大変なんですよ(遠い目)。

以前、WKWebView上にYouTubeの指定URLのムービーを表示するというScriptを掲載したことがありますが、本当はこの上でJavaScriptを実行して指定の再生ポジションに再生位置をジャンプさせるといった処理を行いたかったのですが、WKWebView相手に(任意の)JavaScriptを実行させられず、時間切れで諦めたことがありました(そして絶賛放置中)。なるほど、こう書くんですねー。

あとは、

tell AppleScript

ってなんなんでしょう(^ー^;; 初めて見かける記述のオンパレードがけっこうショッキングです。

自分は「癖のないプログラムを読みやすく書く派」を自称していますが、日本国内にも割と海外のScripterに紹介したい(変わった)人たちがいて、edama2さんとMacLab.さんはその中に必ず入ってくる人たちでしょう。

AppleScript名:指定URLのMS名を取得する v2b.scpt
—
–  Created by: edama2
–  Created on: 2019/09/04
—
use AppleScript
use scripting additions
use framework "Foundation"
use framework "WebKit"

property _js_result : ""

on run
  my main()
end run

on main()
  set my _js_result to ""
  
  
set aURL to "https://w.atwiki.jp/senjounokizuna/pages/1650.html"
  
set myJs to "var result = document.getElementsByTagName(’h3’)[0].innerHTML;
  webkit.messageHandlers.oreore.postMessage(result);"
–>返信用に必要
  
set paramObj to {targetURL:aURL, javascript:myJs}
  
  
my performSelectorOnMainThread:"makeWebContents:" withObject:(paramObj) waitUntilDone:true
  
  
return my _js_result as text
end main

on makeWebContents:paramObj
  
  
set {targetURL:aURL, javascript:myJs} to paramObj
  
  
# 下準備
  
set thisURL to current application’s |NSURL|’s URLWithString:aURL
  
set theRequest to current application’s NSURLRequest’s requestWithURL:thisURL
  
set aConf to current application’s WKWebViewConfiguration’s new()
  
  
#javascriptからname を取り出す
  
set myJs to myJs as text
  
tell AppleScript
    set tmp to text item delimiters
    
set text item delimiters to "webkit.messageHandlers."
    
set stringList to myJs’s text items
    
set aText2 to stringList’s item 2
    
set text item delimiters to ".postMessage("
    
set stringList2 to aText2’s text items
    
set scriptName to stringList2’s item 1
    
set text item delimiters to tmp
  end tell
  
  
#ページ読み込み後に実行するjavascriptの仕込み
  
set userScript to current application’s WKUserScript’s alloc()’s initWithSource:myJs injectionTime:(current application’s WKUserScriptInjectionTimeAtDocumentEnd) forMainFrameOnly:true
  
tell current application’s WKUserContentController’s new()
    addUserScript_(userScript)
    
addScriptMessageHandler_name_(me, scriptName)
    
aConf’s setUserContentController:it
  end tell
  
  
#WebViewを作成&読み込み
  
tell (current application’s WKWebView’s alloc()’s initWithFrame:(current application’s CGRectZero) configuration:aConf)
    setNavigationDelegate_(me)
    
loadRequest_(theRequest)
    
    
set hitF to false
    
repeat (minutes * 1000) times
      set isLoading to isLoading() as boolean
      
if not isLoading then
        set hitF to true
        
exit repeat
      end if
      
delay "0.001" as real
    end repeat
    
  end tell
  
  
return hitF
end makeWebContents:

#javascriptの結果を受信
on userContentController:myUserContentController didReceiveScriptMessage:aMessage
  set my _js_result to aMessage’s body() as text
  
return my _js_result
end userContentController:didReceiveScriptMessage:

★Click Here to Open This Script 

Posted in JavaScript URL | Tagged 10.12savvy 10.13savvy 10.14savvy NSURL NSURLRequest WKUserContentController WKUserScript WKWebView WKWebViewConfiguration | Leave a comment

Safariで表示中のPageの選択中の文字を含む表データを取得

Posted on 9月 3, 2019 by Takaaki Naganoya

Safari上で一部のテキストを選択した「表」のデータをHTMLReaderフレームワークを利用してparseし、2D Listとして取得するAppleScriptです。

Web上の表データをそのまま利用したいケースが多々あります。こんな小さなデータではなく、数百個にわたる表データをインポートして使いたいというケースです。

そのときに作った部品を転用して、より一般的な用途に使えるようにしたのが本Scriptです。ただし、さまざまな用途に使って鍛えたというものでもなく、AppleのWebドキュメントやWikiの内容の抽出など、割と「規則性の高そうなコンテンツ」で利用してみました。

本来は、複数ページの特定の表を指定してデータを取得する用途に用いているものなので、本Scriptのように「選択中の文字列を含む表」といった、のどかな使い方はしません。動作内容がわかりやすいように作り変えたためにこのような仕様になっています。

どこぞのオンラインストアの諸元をまとめた表をWeb上からくすねてくる、とかいう用途だと、割と表が込み入って(JavaScriptを仕込んでソートし直せるようにしてあるとか)いるケースがあるので、どのページのどの表にでもあまねく利用できるという種類のものではありません。

–> Download HTMLReader.framework(To ~/Library/Frameworks)

HTMLReader.frameworkを利用するためには、macOS 10.14以降だとSIPを解除するかScript Debugger上で動かすか、AppleScriptアプレット内に組み込んで実行することになります。

AppleScript名:Safariで表示中のPageの選択中の文字を含む表データを取得.scptd
— Created 2019-09-02 by Takaaki Naganoya
— 2019 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "HTMLReader" –https://github.com/nolanw/HTMLReader

property NSString : a reference to current application’s NSString
property HTMLDocument : a reference to current application’s HTMLDocument
property NSMutableArray : a reference to current application’s NSMutableArray

tell application "Safari"
  set dList to every document –Sometimes "count every document"causes error
  
if length of dList = 0 then return
  
  
–Get URL
  
tell front document
    set aURL to URL
  end tell
  
  
–Get Selected Text
  
set aRes to do JavaScript "var selObj = window.getSelection();
  var selStr = (selObj).getRangeAt(0);
  unescape(selStr);"
in front document
  
  
if aRes = "" then return
end tell

set aRes to filterATableAndPaseCells(aURL, aRes) of me
–> {{"Objective-C and AppleScript class", "Attributes (script term, if different)", "Relationships"}, {"NSObjectImplements the item AppleScript class. For any scriptable Objective-C class that inherits from NSObject, the AppleScript class it implements inherits from the item class (and inherits the class property and the properties property).", "class name (class), properties", ""}, {"NSApplicationImplements the application AppleScript class.", "name, active flag (frontMost), version", "documents, windows (both accessible as ordered relationship)"}, {"NSDocumentImplements the document AppleScript class.", "location of the document’s on-disk representation (path); last component of filename (name); edited flag (modified)", ""}, {"NSWindowImplements the window AppleScript class.", "title (name); various binary-state attributes: closeable, floating, miniaturized, modal, resizable, titled, visible, zoomable", "document"}}

on filterATableAndPaseCells(aURL, aKeyword)
  set aData to (do shell script "curl " & aURL)
  
set aHTML to current application’s HTMLDocument’s documentWithString:(aData as string)
  
  
–Table要素をリストアップ
  
set eList to (aHTML’s nodesMatchingSelector:"table")
  
  
–Table要素のうちSafari上で選択中の文字列を含むものをサーチ(指定データを含むものを抽出)
  
set hitF to false
  
repeat with i in eList
    set cellList to i’s children()’s array()
    
set htmlSource to i’s serializedFragment() as string –HTML source
    
    
if htmlSource contains aKeyword then
      set hitF to true
      
exit repeat
    end if
  end repeat
  
if hitF = false then return false
  
  
–Count columns of Table Header
  
set aTableHeader to (i’s nodesMatchingSelector:"tr")’s firstObject()
  
set hList to aTableHeader’s nodesMatchingSelector:"th"
  
set hStrList to {}
  
repeat with i1 in hList
    set the end of hStrList to i1’s textContent() as string
  end repeat
  
set hLen to length of hStrList –count columns
  
  
–Acquire whole table body contents
  
set aTableBody to (i’s nodesMatchingSelector:"tbody")’s firstObject()
  
set bList to aTableBody’s nodesMatchingSelector:"td"
  
set bbList to {}
  
repeat with i2 in bList
    set the end of bbList to i2’s textContent() as string
  end repeat
  
  
set tbList to makeList1DTo2D(bbList, hLen) of me
  
  
return {hStrList} & tbList
end filterATableAndPaseCells

–1D Listを2D化
on makeList1DTo2D(orig1DList, aMax)
  set tbList to {}
  
set tmpList to {}
  
set aCount to 1
  
  
repeat with i3 in orig1DList
    set j to contents of i3
    
set the end of tmpList to j
    
    
if aCount ≥ aMax then
      set aCount to 1
      
set the end of tbList to tmpList
      
set tmpList to {}
    else
      set aCount to aCount + 1
    end if
  end repeat
  
  
return tbList
end makeList1DTo2D

★Click Here to Open This Script 

Posted in JavaScript Text URL | Tagged 10.12savvy 10.13savvy 10.14savvy HTMLDocument NSMutableArray NSString Safari | 1 Comment

指定URLのMS名を取得する v2a

Posted on 9月 3, 2019 by Takaaki Naganoya

Shane Stanleyが「HTMLをXMLと見立ててアクセスすれば外部フレームワークなしに処理できて簡単だよ」と、送ってくれたサンプルScriptです。

2つの意味で焦りました。

(1)指定URLの内容をダウンロードするのに、「initWithContentsOfURL:」で処理
(2)この調子で処理したら、お手軽にREST APIも呼べそうな雰囲気

いろいろ考えさせられる内容でもあります。こういう「それ自体で何か製品を構成できるほどのサイズの処理じゃないけど、何かに絶対に使ってますよね」的な処理をBlogで公開しておくことのメリットを感じつつ、XML処理とか正規表現の処理が個人的に不得意なので、とても参考になります。

自分の用途が残念な(そんなに生産的でもなく趣味的な、という意味で)ものだったので、恐縮するばかりですー(オンラインゲームの機体のデータをWikiからまるごと引っこ抜くというものだったので)。

AppleScript名:get a title.scptd
—
–  Created by: Shane Stanley
–  Created on: 2019/09/03
—
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

— classes, constants, and enums used
property NSXMLDocumentTidyHTML : a reference to 512
property NSXMLDocument : a reference to current application’s NSXMLDocument
property NSString : a reference to current application’s NSString
property |NSURL| : a reference to current application’s |NSURL|
property HTMLDocument : a reference to current application’s HTMLDocument
property NSMutableArray : a reference to current application’s NSMutableArray

set aURL to "https://w.atwiki.jp/senjounokizuna/pages/1650.html"
set aRes to getTitleFromAURL(aURL) of me
–> "ジム・スナイパー  RGM-79(G)"

on getTitleFromAURL(aURL)
  set theNSURL to |NSURL|’s URLWithString:aURL
  
set {theXML, theError} to NSXMLDocument’s alloc()’s initWithContentsOfURL:theNSURL options:NSXMLDocumentTidyHTML |error|:(reference)
  
if theXML is missing value then error theError’s localizedDescription() as text
  
repeat with i from 2 to 7 by 1
    set theNodes to (theXML’s nodesForXPath:("//h" & i) |error|:(missing value))
    
if theNodes’s |count|() is not 0 then return (theNodes’s firstObject()’s stringValue()) as text
  end repeat
  
error "Header is missing"
end getTitleFromAURL

★Click Here to Open This Script 

Posted in Text URL XML | Tagged 10.12savvy 10.13savvy 10.14savvy HTMLDocument NSMutableArray NSString NSURL NSXMLDocument NSXMLDocumentTidyHTML | Leave a comment

指定URLのMS名を取得する v2

Posted on 9月 3, 2019 by Takaaki Naganoya

指定URLの初出の指定タグ要素を抽出するAppleScriptです。

たまたま、戦場の絆Wikiから各種データを自動で抽出するAppleScriptを書いたときについでに作った、各ページのh2タグで囲まれた機種名を取り出す処理部分です。


▲このデータだけ機種名がh3タグでマークされていて、例外を吸収するために汎用性を高めたのが本ルーチン

Webサイトからのデータ取り出しは割と重要な技術です。それを容易に可能にするHTMLReaderのようなFrameworkは、とても重要なパーツといえます。HTMLReaderがなければ、こんな簡単に処理することはできなかったでしょう(この些細な処理を、ではなくやりたい処理全体に対しての評価)。

# WebスクレイピングはScripter必須の技術なので、Safari/ChromeでDOMアクセス派や正規表現でソースから抽出派、XMLとして解釈してXPathでアクセスする派などいろいろありそうですが、自分はHTMLReaderを使って楽をしてデータを取り出す派 といえます

特定のURL上のHTMLの特定のタグ要素のデータを抜き出すという処理であり、かならずしもどのサイトでも万能に処理できるというわけでもありません。ただ、Wikiのような管理プログラムでコンテンツを生成しているサイトから各種データを抜き出すのは、生成されるHTMLの規則性が高くて例外が少ないため、割と簡単です。

HTMLReaderをAppleScriptから呼び出し、表データを2D Listとして解釈するなど、データ取り出しが簡単にできるようになったことは意義深いと思われます。

macOS 10.13まではスクリプトエディタ/Script Debugger上でScriptを直接実行できます。macOS 10.14以降ではSIPを解除するか、Script Debugger上で実行するか、本記事に添付したようなアプレット(バンドル内にFramework同梱)を実行する必要があります。

HTMLReaderについては、Frameworkにするよりもアプリケーション化してsdefをつけて、AppleEvent経由で呼び出す専用のバックグラウンドアプリケーションにすることも考えるべきかもしれません。ただ、すべての機能についてsdefをかぶせるためには、「こういうパターンで処理すると便利」という例をみつけてまとめる必要があります。つまり、sdefをかぶせると返り値はAppleScript的なデータに限定されるため、何らかの処理が完結した状態にする必要があります。

–> Download tagElementPicker.zip (Code Signed executable Applet)

–> Download HTMLReader.framework (To ~/Library/Frameworks)

Webコンテンツのダウンロードは、本ルーチンではcurlコマンドで実装していますが、いろいろ試してみたところ現時点で暫定的にこれがベストという判断を行っています。

もともと、macOS 10.7でURL Access Scriptingが廃止になったため、Webアクセスのための代替手段を確保することはScritperの間では優先順位の高い調査項目でした。

curlコマンドはその代替手段の中でも最有力ではあったものの、macOS 10.10以降のAppleScript処理系自体のScripting Bridge対応にともない、NSURLConnectionを用いたアクセスも試してきました。同期処理できて、Blocks構文の記述が必須ではないため、実装のための難易度がCocoa系のサービスでは一番低かったからです。

ただし、NSURLConnection自体がDeprecated扱いになり、後継のNSURLSessionを用いた処理を模索。いろいろ書いているうちに、処理内容がapplescript-stdlibのWebモジュールと酷似した内容になってきた(もともと同ライブラリではNSURLSessionを用いていたため)ので、この機能のためだけにapplescript-stdlibを組み込んで使ってみたりもしました。

しかし、applescript-stdlibのWebモジュールは連続して呼び出すと処理が止まるという代物であり、実際のプログラムに組み込んで使うのは「不可能」でした。1つのURLを処理するには問題はないものの、数百個のURLを処理させると止まることを確認しています。おまけに処理本体にも自分自身のsdefを用いた記述を行っているためメンテナンス性が最悪で、中身をいじくることは(自分には)無理です。

# applescript-stdlibのWebモジュールではUserAgent名がサイト側の想定しているものに該当せずアクセスを拒否されたのか、Webモジュール側の内部処理がまずいのかまでは原因追求できていません。連続処理を行うと止まるという症状を確認しているだけです

NSURLSessionによる処理については、applescript-stdlibのWebモジュールを参考にしつつもう少し書き慣れる必要がある一方で、いろいろモジュール単位で差し替えて試行錯誤したところ、curlコマンドは遅くなったり処理が止まったりすることもなく利用できています。

それでも、curlコマンド以外の選択肢を用意しておくことは重要であるため、NSURLSessionも引き続き追いかけておきたいところです。

AppleScript名:指定URLのMS名を取得する v2.scptd
— Created 2019-09-02 by Takaaki Naganoya
— 2019 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "HTMLReader" –https://github.com/nolanw/HTMLReader

property NSString : a reference to current application’s NSString
property HTMLDocument : a reference to current application’s HTMLDocument
property NSMutableArray : a reference to current application’s NSMutableArray

set aURL to "https://w.atwiki.jp/senjounokizuna/pages/1650.html"
set aRes to getTitleFromAURL(aURL) of me
–> "ジム・スナイパー  RGM-79(G)"

on getTitleFromAURL(aURL)
  set aData to (do shell script "curl " & aURL)
  
set aHTML to current application’s HTMLDocument’s documentWithString:(aData as string)
  
  
–Levelの高いHeader Tagから順次低い方にサーチして返す
  
repeat with i from 2 to 7 by 1
    set aHeaderTag to "h" & i as string
    
set eList to (aHTML’s nodesMatchingSelector:aHeaderTag)
    
    
if (eList as list) is not equal to {} then
      return (eList’s firstObject()’s textContent()) as string
    end if
  end repeat
  
  
error "Header is missing"
end getTitleFromAURL

★Click Here to Open This Script 

Posted in Text URL | Tagged 10.12savvy 10.13savvy 10.14savvy HTMLDocument NSMutableArray NSString | Leave a comment

Post navigation

  • Newer posts

電子書籍(PDF)をオンラインストアで販売中!

Google Search

Popular posts

  • macOS 13, Ventura(継続更新)
  • アラートダイアログ上にWebViewで3Dコンテンツを表示(WebGL+three.js)v3
  • Xcode 14.2でAppleScript App Templateを復活させる
  • UI Browserがgithub上でソース公開され、オープンソースに
  • macOS 13 TTS Voice環境に変更
  • 2022年に書いた価値あるAppleScript
  • ChatGPTで文章のベクトル化(Embedding)
  • 新発売:AppleScriptからSiriを呼び出そう!
  • iWork 12.2がリリースされた
  • 従来と異なるmacOS 13の性格?
  • 新発売:CotEditor Scripting Book with AppleScript
  • macOS 13対応アップデート:AppleScript実践的テクニック集(1)GUI Scripting
  • AS関連データの取り扱いを容易にする(はずの)privateDataTypeLib
  • macOS 13でNSNotFoundバグふたたび
  • macOS 12.5.1、11.6.8でFinderのselectionでスクリーンショット画像をopenできない問題
  • 新発売:iWork Scripting Book with AppleScript
  • ChatGPTでchatに対する応答文を取得
  • Finderの隠し命令openVirtualLocationが発見される
  • macOS 13.1アップデートでスクリプトエディタの挙動がようやくまともに
  • あのコン過去ログビューワー(暫定版)

Tags

10.11savvy (1101) 10.12savvy (1242) 10.13savvy (1390) 10.14savvy (586) 10.15savvy (434) 11.0savvy (277) 12.0savvy (186) 13.0savvy (59) CotEditor (60) Finder (47) iTunes (19) Keynote (99) NSAlert (60) NSArray (51) NSBezierPath (18) NSBitmapImageRep (20) NSBundle (20) NSButton (34) NSColor (51) NSDictionary (27) NSFileManager (23) NSFont (18) NSImage (41) NSJSONSerialization (21) NSMutableArray (62) NSMutableDictionary (21) NSPredicate (36) NSRunningApplication (56) NSScreen (30) NSScrollView (22) NSString (117) NSURL (97) NSURLRequest (23) NSUTF8StringEncoding (30) NSView (33) NSWorkspace (20) Numbers (57) Pages (38) Safari (41) Script Editor (20) WKUserContentController (21) WKUserScript (20) WKUserScriptInjectionTimeAtDocumentEnd (18) WKWebView (23) WKWebViewConfiguration (22)

カテゴリー

  • 2D Bin Packing
  • 3D
  • AirDrop
  • AirPlay
  • Animation
  • AppleScript Application on Xcode
  • beta
  • Bluetooth
  • Books
  • boolean
  • bounds
  • Bug
  • Calendar
  • call by reference
  • Clipboard
  • Code Sign
  • Color
  • Custom Class
  • dialog
  • drive
  • exif
  • file
  • File path
  • filter
  • folder
  • Font
  • Font
  • GAME
  • geolocation
  • GUI
  • GUI Scripting
  • Hex
  • History
  • How To
  • iCloud
  • Icon
  • Image
  • Input Method
  • Internet
  • iOS App
  • JavaScript
  • JSON
  • JXA
  • Keychain
  • Keychain
  • Language
  • Library
  • list
  • Locale
  • Machine Learning
  • Map
  • Markdown
  • Menu
  • Metadata
  • MIDI
  • MIME
  • Natural Language Processing
  • Network
  • news
  • Noification
  • Notarization
  • Number
  • Object control
  • OCR
  • OSA
  • PDF
  • Peripheral
  • PRODUCTS
  • QR Code
  • Raw AppleEvent Code
  • Record
  • rectangle
  • recursive call
  • regexp
  • Release
  • Remote Control
  • Require Control-Command-R to run
  • REST API
  • Review
  • RTF
  • Sandbox
  • Screen Saver
  • Script Libraries
  • sdef
  • search
  • Security
  • selection
  • shell script
  • Shortcuts Workflow
  • Sort
  • Sound
  • Spellchecker
  • Spotlight
  • SVG
  • System
  • Tag
  • Telephony
  • Text
  • Text to Speech
  • timezone
  • Tools
  • Update
  • URL
  • UTI
  • Web Contents Control
  • WiFi
  • XML
  • XML-RPC
  • イベント(Event)
  • 未分類

アーカイブ

  • 2023年9月
  • 2023年8月
  • 2023年7月
  • 2023年6月
  • 2023年5月
  • 2023年4月
  • 2023年3月
  • 2023年2月
  • 2023年1月
  • 2022年12月
  • 2022年11月
  • 2022年10月
  • 2022年9月
  • 2022年8月
  • 2022年7月
  • 2022年6月
  • 2022年5月
  • 2022年4月
  • 2022年3月
  • 2022年2月
  • 2022年1月
  • 2021年12月
  • 2021年11月
  • 2021年10月
  • 2021年9月
  • 2021年8月
  • 2021年7月
  • 2021年6月
  • 2021年5月
  • 2021年4月
  • 2021年3月
  • 2021年2月
  • 2021年1月
  • 2020年12月
  • 2020年11月
  • 2020年10月
  • 2020年9月
  • 2020年8月
  • 2020年7月
  • 2020年6月
  • 2020年5月
  • 2020年4月
  • 2020年3月
  • 2020年2月
  • 2020年1月
  • 2019年12月
  • 2019年11月
  • 2019年10月
  • 2019年9月
  • 2019年8月
  • 2019年7月
  • 2019年6月
  • 2019年5月
  • 2019年4月
  • 2019年3月
  • 2019年2月
  • 2019年1月
  • 2018年12月
  • 2018年11月
  • 2018年10月
  • 2018年9月
  • 2018年8月
  • 2018年7月
  • 2018年6月
  • 2018年5月
  • 2018年4月
  • 2018年3月
  • 2018年2月

https://piyomarusoft.booth.pm/items/301502

メタ情報

  • ログイン
  • 投稿フィード
  • コメントフィード
  • WordPress.org

Forum Posts

  • 人気のトピック
  • 返信がないトピック

メタ情報

  • ログイン
  • 投稿フィード
  • コメントフィード
  • WordPress.org
Proudly powered by WordPress
Theme: Flint by Star Verte LLC