// Callback used by the HTML window we create below
function attributeWindowCallback(val)
{
let obj = JSON.parse(val);
if (obj.StrokesPlusHTMLWindow) {
var handle = new IntPtr(parseInt(obj.StrokesPlusHTMLWindow.Handle))
sp.StoreHandle("attributeWindowHandle",handle);
}
else if (obj.action)
{
switch(obj.action) {
case "Close":
sp.WindowFromHandle(sp.GetStoredHandle("attributeWindowHandle")).SendClose();
break;
}
}
}
// Opens an HTML window to a URL (this post), waits 2 seconds, then looks for a div and shows an
// alert with the html of the element, then closes the HTML window
sp.HTMLWindow("Find Element", //Window title
"https://forum.strokesplus.net/posts/t8539-Can-the-Sprogram-obtain-the-attribute-values-of-the-specified-elements-in",
"attributeWindowCallback", //message callback
`setTimeout(function(){ // Script to execute on document create
alert($('.selectionQuoteable').html());
window.chrome.webview.postMessage({ action: 'Close'});
}, 2000);`, // Waits 2 seconds, then gets an element via jQuery
"", // window ID
false); // include jQuery/bootstrap - ignored for file/url
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter