简体   繁体   中英

Bookmarklet to open new tab with Xpath from current page as URL arguments

I would like to create a bookmarklet that can use 3 Xpath from the current page to build a Url with the xpath as the arguments.

I have tried to find an existing bookmarklet that was similar that I would be able to modify. I am not a programmer, just someone trying to improve the efficiency of a process they have to do frequently.

Here is the simple example to read the value using the xpath and then open new tab with the xpath output.

Save the below javascript as a bookmarklet and click when you are on any post to see the origninal post user profile.

javascript:{
    var xResults = document.evaluate("(//div[@class='post-signature owner grid--cell']//a)[2]", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
    var url = xResults.snapshotItem(0).href;
    window.open(url);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM