Giter VIP home page Giter VIP logo

googlechromelabs / link-to-text-fragment Goto Github PK

View Code? Open in Web Editor NEW
373.0 18.0 34.0 1.58 MB

Browser extension that allows for linking to arbitrary text fragments.

Home Page: https://chrome.google.com/webstore/detail/link-to-text-fragment/pbcodcjpfjdpcineamnnmbkkmkdpajjg

License: Apache License 2.0

JavaScript 98.42% HTML 1.58%
text-fragments text-fragment text-fragment-url fragment-directive chrome-extension chrome-extensions scroll-to-text-fragment

link-to-text-fragment's Introduction

Link to Text Fragment

Installation

You can install the extension in your browser of choice:

Usage

The Link to Text Fragment extension allows for the easy creation of text fragment URLs via the context menu:

  1. Select the text that you want to link to.
  2. Right-click and choose "Copy Link to Selected Text" from the context menu.
  3. If the link creation succeeded, the selected text will be briefly highlighted in yellow.
  4. Paste your link wherever you want to share it.

Text fragment selected on a webpage and contextmenu showing "Copy Link to Selected Text"

Background

The Text Fragments specification adds support for specifying a text snippet in the URL fragment.

#:~:text=[prefix-,]textStart[,textEnd][,-suffix]

When navigating to a URL with such a fragment, the user agent can quickly emphasize and/or bring it to the user's attention.

Try it out by clicking on this link: https://wicg.github.io/scroll-to-text-fragment/#ref-for-fragment-directive:~:text=%23%3A~%3Atext%3D%5Bprefix%2D%2C%5DtextStart%5B%2CtextEnd%5D%5B%2C%2Dsuffix%5D.

Acknowledgements

Text Fragments was implemented and specified by Nick Burris and David Bokan, with contributions from Grant Wang. The extension icon is courtesy of Rombout Versluijs.

License

The extension's source code is licensed under the terms of the Apache 2.0 license.

This is not an official Google product. By installing this item, you agree to the Google Terms of Service and Privacy Policy at https://www.google.com/intl/en/policies/.

link-to-text-fragment's People

Contributors

ashuvax avatar dependabot[bot] avatar herrkaefer avatar minho42 avatar tomayac avatar yangsu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

link-to-text-fragment's Issues

Unable to link to text

I have tried multiple times, but when I create a link to text the URL only goes to the page and not the text.

Is there some way to fix this?

Questions about the privacy and security docs for GoogleChromeLabs / Link-to-text-fragment

Questions about the privacy and security docs for GoogleChromeLabs / Link-to-text-fragment

Contact:      Privacy Officer/Legal
From:          ECNO VASP Team
Date:           March 02, 2022
RE:               Link to Text Fragment - Free
 
If you are not the correct person to receive this message, please forward it to the appropriate contact.
 
Background
The Education Computing Network of Ontario (ECNO) and the Ontario Association of School Business Officials (OASBO) have partnered to establish a service to review software, applications, and web services, etc. for Ontario school boards.
 
ECNO is comprised of Ontario’s 72 public and Catholic English and French school boards who collaboratively find and execute effective IT solutions.  The Ontario Association of School Business Officials (OASBO) brings professionals together who are committed to collaborative development, sharing and promotion of leading business practices in support of students.   Both ECNO and OASBO operate in Ontario, Canada.
 
An expert team, known as the Vetting Applications for Security and Privacy (VASP) team, was established to perform privacy, security and liability risk assessments. The assessment is based on the Student Digital Privacy Standard developed for Ontario Schools Board (copy attached).  It identifies gaps between the function of the software and the vendor’s privacy policy, terms of service and other related documents, apparent security/privacy challenges in the use of the application, and assigns a risk score.   Boards are provided with risk assessment reports which outline mitigating strategies to minimize the impact of any privacy, security and/or liability risks to inform their decision.  Ultimately, boards alone bear full responsibility for the final decision about whether to use the software based on their risk tolerance, ability to implement mitigation strategies, and, where applicable, to negotiate acceptable contract language.
 
Assessment Comments/Questions
The assessment is being conducted because one or more of Ontario’s school boards have requested the app be assessed.  The first stage has been completed and risk assessment score has been determined; however, it has generated questions that require clarification.
 
Prior to finalizing the risk assessment and communicating the results to boards, we are seeking your response to the following comments/questions.  Your feedback is important and we ask that you forward it to [email protected] by the due date listed below.
 
Please note, should we not receive your reply, the report will be posted with the outstanding questions which will result in a high risk assessment.  We look forward to including your input to provide Ontario school boards with the most comprehensive overview of the app.
 
Comments/Questions Arising from the Assessment
 
1.  To what privacy legislation does the app/service comply?
 
2.  Does the app track student behavior outside of the app (e.g., browsing habits, search queries, use of social media)?
 
3.  Is there a privacy/security policy in place that includes a comprehensive security program (that is based on one or more industry frameworks such as NIST, ISF, ISO, COBIT, CIS, etc.) or controls for protecting systems and user data?
 
4.  Are industry standards for security followed and can provide reports, evidence, certifications, or assurance regarding the presence of security controls (e.g. SOC 2 / SOC 3, FedRAMP, CSA STAR, ISO, etc.) be provided?
 
5.  Is data encrypted at rest?
 
6.  Is there a breach response protocol including containment, notification and remediation in place?
 
7.  Are users/schools/boards notified when a security or data breach of personal information occurs?  If so, is it by direct or indirect notification?
 
8.  How are disputes resolved--by mediation, arbitration or litigation?  If by arbitration, do both parties control the terms?
 
9.  Where does the App/Software/Web Service store files?
 
 
Response Requested by:  March 15, 2022

Is it possible to generate a rich URL rather than the raw one created?

(FYI--not a coder)

Hey Thomas -- this could probably be one of the most useful extensions I've found in Chrome as it basically makes Deep Linking in web pages possible. Kinda odd how researchers aren't scrambling to install this. Anyway, I use this app as part of my research / note-taking workflow and have to do a few extra steps to turn the links generated into readable text. I was wondering if there is a way (or maybe through a workaround) to have generated link instead copy the highlighted text for easy pasting. If this isn't possible through the app itself, any useful advice on workarounds to achieve this will be highly appreciated

Thanks!

Doesn't break on <br />

I'm trying to make a link to elle a brisé on https://leconjugueur.lefigaro.fr/conjugaison/verbe/briser_feminin.html.

If I just put the text at the right place (#:~:text=elle a brisé), it doesn't work.

When I use "Copy link to selected text" while highlighting elle a brisé, I get #:~:text=briseelle a brisenous, which is incorrect; it's not the text I've highlighted and it doesn't make any sense.

I've tried using the prefix and suffix as... a prefix and a suffix according to the README.md (#:~:text=brise-,elle a brise,-nous), but that doesn't work either.

The previous and next lines seems to be merged with the first and last words respectively regardless of the <br /> separating them. Not only that, but it also doesn't seem to be able to separate one word from its prefix & suffix.

The extension should work offline also

The extension should be tested to make it work offline.
E.g., if we are browsing file:///home/xyz.html
then we should be able to make perfectly legitimate
file:///home/xyz.html#bla_bla links.

No matter for testing, or interpage linking, the extension should work
perfectly fine offline too.

Alert upon failure

If for some reason it is not possible to make a link,
the extension should at least
issue an alert, instead of doing nothing.

Else the user will just end up fruitlessly trying to paste what he discovers
is not what he intended.

Generate URL Strips Part of the Original URL

I was on this page https://www.ivelt.com/forum/viewtopic.php?p=2245310 and used the extension to generate a link and it generated the following, which is not a working link to the page: https://www.ivelt.com/forum/viewtopic.php#post_content2244975:~:text=%D7%91%D7%90%D7%96%D7%95%D7%A0%D7%93%D7%A2%D7%A8%D7%A2.

Why doesn't it leave the ?p=2245310 part of the original URL (like https://www.ivelt.com/forum/viewtopic.php?p=2245310#post_content2244975:~:text=%D7%91%D7%90%D7%96%D7%95%D7%A0%D7%93%D7%A2%D7%A8%D7%A2) which would be a working link to text fragment?

dynamically build the link

is there a way to build programmatically generate link to the highlighted text.
for example: I am looking to create C# function that accepts url and the paragraph to be highlighted that returns the url.

generateLTFlink(string url, string paragraphTobehighlighted){

return ltfurl;
}

here is what I tried so far and it ran

` public static string GetTextHighLighterUrl(string firstValidFileUrl, string answer)
{
var sb = new StringBuilder();
var textHighLighterUrl = string.Empty;
var highlightText = answer.Replace(firstValidFileUrl, "");
highlightText = highlightText.Replace("()", "");
highlightText = $"{Regex.Replace(highlightText, @"[[^]]*]", "")}"; // remove text within square brackets.
highlightText = $"{Regex.Replace(highlightText, @"\t|\r", "$$")}";
highlightText = RemoveExtraSentences(highlightText, "$$").Trim();
highlightText = highlightText.Replace("$$", "");
highlightText = FilterWhiteSpaces(highlightText);
highlightText = highlightText.Replace("$", "");
highlightText = highlightText.Replace("(/)", "");
highlightText = highlightText.Replace(""", "%22");
highlightText = highlightText.Replace(",", "%2C");

        if (!ContainsOnlyAlphaNumericCharacters(highlightText))
        {
            //remove sentences with special char and get a safe sentence
            highlightText = GetCleanSentence(highlightText);
        }


        if (highlightText.Length > 50)
        {
            var textArrayn = highlightText.Split("\n"); //if ans contains \n
            if (highlightText.Contains("\n") && textArrayn?.Length == 2)
            {
                textArrayn = highlightText.Split("\n");
            }
            else
            {
                textArrayn = new List<string>().ToArray();
            }
            var textArray = highlightText.Split();
            var n = textArray.Length;
            sb.Clear();
            for (int i = 0; i < 5; i++)
            {
                if (IsValidIndex(i, textArray))
                {
                    sb = sb.Append(textArray[i] + "%20");
                }
            }
            var start = sb.ToString();
            if (start.Contains(","))
            {
                var tempStart = start.Split(",");
                start = tempStart[0].ToString();
            }


            if (textArrayn.Length > 0)
            {
                start = textArrayn[0].ToString();  //if ans contains \n then start from there
            }
            sb.Clear();
            for (int i = n - 6; i <= n; i++)
            {
                if (IsValidIndex(i, textArray))
                {
                    if (i != n - 1)
                    {
                        sb = sb.Append(textArray[i] + "%20");
                    }
                    else
                    {
                        sb = sb.Append(textArray[i]);
                    }

                }
            }
            var end = sb.ToString().Trim();
            end = end.Replace(",", "%2C");
            sb.Clear();
            sb = sb.Append(firstValidFileUrl).Append("#object:~:text=").Append(start).Append(",").Append(end);
            textHighLighterUrl = sb.ToString();
            sb.Clear();
        }
        else
        {
            sb.Clear();
            highlightText = highlightText.Replace(" ", "%20");
            if (!string.IsNullOrEmpty(highlightText))
            {
                sb = sb.Append(firstValidFileUrl).Append("#object:~:text=").Append(highlightText);
            }
            else
            {
                sb = sb.Append(firstValidFileUrl);
            }

            textHighLighterUrl = sb.ToString();
            sb.Clear();
        }
        textHighLighterUrl = $"{Regex.Replace(textHighLighterUrl, @"\.{2,}", "")}";//edge cases.Remove Multiple dots
        textHighLighterUrl = textHighLighterUrl.Replace(",%20,", ",");

        return textHighLighterUrl;
    }`

Jumps away from link-to-text link

I'm attempting to link jump for citation purposes on the government cdc website. I use the link-to-text app on chrome and paste it appropriately but it will jump to my desired highlighted text and then jump to the top of the page quickly thereafter.

Im mad

for manipulation issues, just that

Don't insist on Unique Text (make it an option)

A lot of time I'd be happy with it working on the first match. I believe this would be the extension forcing this and not chrome which I'm guessing would go to the first match.

Maybe display the message but still copy the link in case the user is happy with this (that is make it a suggestion rather than an error).

Not generating enough context

Here's an interesting case:

I was trying to copy a link to this text but the extension gave up due to uniqueness.

Turns out on GitHub it's common to have text quoted which means large sections will be non unique. It's a bit of an edge case for our algorithm.

However, in this case, simply using the last few words of the previous numbered list entry works as disambiguating context. I haven't had a chance to dig into the code yet but it looks like the extension isn't (correctly) crossing the block boundary to find context when the match starts at a block boundary.

Optionally URL-encode parentheses

The Chrome extension created this link for me:
https://wiki.eclipse.org/Tycho/Reference_Card#:~:text=include%20source%20bundles)-,target%20runtime%20environment,-Specify%20which%20environments

Do you see the closing parenthesis ")" in the URL? That is a problem, just like an opening parenthesis, if you want to use that URL in a markdown documentlink, because the format is [My description](https://my.url.org/foo/bar). Now when using the URL in a link directly here on GitHub, it looks like this:

My description-,target%20runtime%20environment,-Specify%20which%20environments)

If I manually URL-encode the closing parenthesis as %29, the link looks OK:

My description

So please, enable the user to specify a list of characters which should be URL-encoded by default.

Show toast/notification message for success or failed to make text link fragment.

Link To Text Fragment will be new chapter for Web Browser, I think. Thanks for thought out such of things.

I don't know, how user will take to see success or failed toast/notification message while they're copy link for Text Highlighting through Link to Text Fragment.

But I saw, some of websites not working to make text highlighting link through LTTF. Example website : Chrome Webstore.

Created link does not contain dot char, causing it to break

I tried to create a link to the following text, but I had to insert the dot character "." after "exception" into the link myself to make it work.

Broken link created via select + right-click > Copy Link to selected text:
https://docs.microsoft.com/en-us/archive/msdn-magazine/2009/february/clr-inside-out-handling-corrupted-state-exceptions#:~:text=execution-,corrupted%20state%20exceptions,-In

Working link after fixing it manually:
https://docs.microsoft.com/en-us/archive/msdn-magazine/2009/february/clr-inside-out-handling-corrupted-state-exceptions#:~:text=execution.-,corrupted%20state%20exceptions,-In

Interfering with Middle-Click

While in a web browser I often use the middle mouse click on a link to open the link in a new tab.  However recently this stop working so I have had to start using Ctrl-Click.  I finally decided to search for a solution to this issue.  One of the first hits I found indicated that some extensions can interfere with the middle-click. So I disabled all my extensions to see if this was my issue and found that middle click started working again. Re-enabling and retesting it ended up being link-to-test-fragment was the culprit.

Safari Extension Doesn't Work

Attempting to copy the link to any text will copy nothing. I have attempted with both rich and raw modes. I'm using Safari 15 on MacOS Monterey.
image

Control+Shift+L clashes with Google Docs shortcut

When I do ctrl+shift+l to left align on Google Docs, the popup appears telling me I haven't selected anything to copy the link to. This also prevents the shortcut from working (the text is still center aligned). I am on a Chromebook, if that has anything to do with the shortcut not working. I'm a little disappointed that 3 Google products clash and don't work together properly.

Asking for too many permissions

IIUC, the extension should be able to do its work by just inspecting the single page on which I've clicked its context menu item, but when I click that context menu item in Chrome, it asks to "Read and change all your data on the websites you visit."

Persistent error

I'm getting an error anytime I try to use the Link to Text Fragment extension in Chrome.

No matter how much text I select, I always get this error:
Screen Shot 2020-07-30 at 11 52 06 AM

Can you help me understand what I'm doing wrong?

A doubt

I just needed to know that can we only highlight one text and not multiple texts in different paragraphs in a web page?

Issue with Citrix.com links (with or without # sign)

Suggestion: Add option to make a bookmark

I just found this while looking for ways to bookmark flower seed entries on a plain-text website. Works great in Firefox 95 so far. Thank you for supporting multiple clients!

One suggestion, if possible, is for there to be an option to create a bookmark of the highlighted text, with the bookmark's name being the highlighted text itself.

I can do this myself by creating the bookmark ahead of time and copying and pasting the text in it, but this could cut down on the amount of copying and pasting to get the same result. It'd be understandable if this isn't possible due to security issues or it being outside the scope of the extension, though.

How to make it working with PDF when opened in browser

Did it actually work for pdf file(opened in chromium).? It did not work for me. For HTML files it is working fine.
For PDF file opened in chrome/chromium, it will show the context menu to "copy link to selected text" but actually no link is getting copied.

Text Fragment Not Located from Link Activated in Telegram Messenger

I am using the Firefox 93 version of Link-to-text-fragment, on a Windows 7 PC, which also runs Telegram-messenger.

Posting the raw link to a text fragment on a webpage to Telegram, and subsequently activating it in Telegram, opens the associated webpage URL, but the page does not scroll to the location of the linked text fragment.

Thank you.

Not highlighting text on Chrome

When trying to highlight the following text:

March 29th, 2022 - Windows 473.33, Linux 470.62.26

From this page: https://developer.nvidia.com/vulkan-driver

Your extension generates the following URL:

https://developer.nvidia.com/vulkan-driver#:~:text=march%2029th%2C%202022%20-%20windows%20473.33%2C%20linux%20470.62.26

When you open the URL above on Firefox 98.0.2, it highlights the text successfully, but the same does not happen on Chrome 100.0.4896.60.

Using Chrome's built-in "Copy link to highlight" feature, this URL is generated instead (and it works on both Firefox and Chrome):

https://developer.nvidia.com/vulkan-driver#:~:text=March%2029th%2C%202022%20%2D%20Windows%20473.33%2C%20Linux%20470.62.26

Maybe it could help you find a solution.

Thank you for this extension by the way!

Opening link right after start firefox doesn't scroll to target

System: windows 10 and arch linux
Browser: firefox 88.0.1
Extension version: 2.0.1

Steps to reproduce

same for private window or not

firefox --private-window https://www.cyberciti.biz/faq/bash-shell-change-the-color-of-my-shell-prompt-under-linux-or-unix/#:~:text=you%20also%20need%20to%20put%20%5C%5B%20and%20%5C%5D%20around%20any%20color%20codes%20so%20that%20bash%20does%20not%20take%20them%20into%20account%20when%20calculating%20line%20wraps.

Expected behavior

Opening link right after start firefox will scroll to target.

Actual behavior

Opening link right after start firefox doesn't scroll to target.
I need to right click and copy another text as link in order to make the extension work.
Details see attached screen capture video.

screen3.mp4

Copy Exact Link to Selected Text

I'd like the URL to contain the full quote of the text from the page. As such, instead of generating a URL using both textStart and textEnd I would like an option to copy a URL for an "exact" search (using textStart only and leaving textEnd undefined).

This way I can decode the URL to get the full quotation without visiting the site, it also will invalidate the URL (which sometimes I want) if the text on the page changes and I still know what the site said when the URL was previously generated.

I propose adding another context menu option in addition to the existing "Copy Link to Selected Text", perhaps captioned as "Copy Exact Link to Selected Text".

algorithm to generate that hyperlink

Where can I see the logic that generates the hyperlink from the selected paragraph when we right-click on the selected text. I am trying to see if I can generate that hyperlink programmatically by sending the text to be highlighted as input params.

Not working with mutation (German Umlaut (ä,ö,ü))

Plugin doesn't work in ServiceNow - not long enough

Hi there,
I'm unable to use this to generate a link in ServiceNow, it tells me "Couldn't create a unique link, please select a longer sequence of words." when I select a longer sequence it doesn't solve the issue.

2021-10-18.08-00-04.mp4

See the screen recording.

Thanks!

Not working on Chrome 93 on Mac

When I try to create a link, the background page shows the following errors:

Unchecked runtime.lastError: Cannot create item with duplicate id copy-link
_generated_background_page.html:1 Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.
background_script.js:149 Uncaught (in promise) Error: Failed to connect to the specified tab.
    at background_script.js:149
(anonymous) @ background_script.js:149
async function (async)
startProcessing @ background_script.js:125
(anonymous) @ background_script.js:120
async function (async)
(anonymous) @ background_script.js:115

Couldn't create a unique link for text, selected with a triple-click

There is an alert when you try to create a link on the text that was selected by triple-click with the left button of the mouse on any site.

Steps to reproduce

  1. Open any site with text, for example, Wikipedia
  2. Press the left button three times
  3. Press the right button, choose "Copy link to selected text"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.