GithubHelp home page GithubHelp logo

onenotedev / webclipper Goto Github PK

View Code? Open in Web Editor NEW
336.0 336.0 53.0 69.1 MB

The OneNote Web Clipper extension

Home Page: https://www.onenote.com/clipper

License: MIT License

JavaScript 18.02% HTML 0.21% TypeScript 79.79% Less 1.98%

webclipper's People

Contributors

ajayalli-msft avatar akhileshgarg21 avatar anbiniyar avatar anbinm-msft avatar arpankundu97 avatar dependabot[bot] avatar dhruvm7 avatar gopal29392 avatar iconix avatar janehazen avatar jogonzal avatar ksboora avatar larsendaniel avatar leakymemory avatar maghos-ms avatar manu8996 avatar manusing8 avatar mttwc avatar s-n-d-p avatar sugupta427 avatar susinh avatar vadobre avatar varaizad avatar vishaalk 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  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

webclipper's Issues

Tooltips are showing too often

There is currently no way to taper off how often the tooltip shows.

Mitigation is to give users an option to turn them off and turn them off after they've been seen a certain times and if the user has ever clipped the content type we are trying to inform them about.

Safari: Page needs to be refreshed after extension install

Because in Safari we inject a listener into every page which is needed when we invoke the clipper, after you install (or upgrade) the extension any existing pages need to be refreshed before the clipper will work.

We need to detect this case and prompt the user to refresh the page before invoking the clipper.

Show a better error message when cookies are blocked by the browser

Because we still rely on the browser's ability to write cookies on the www.onenote.com domain, there is a possibility that another extension, or the browser itself if certain options are set, can block that cookie write. We should try to detect this situation and let the user know how to get around it. Nearly always the answer is to add an exception for https://www.onenote.com.

The challenge here is that the message itself will need to be somewhat generic as we will have no idea what is actually blocking the cookie. Hopefully we can write in a way that the user can just "figure it out".

Authentication errors need to be bubbled up to the user

When the authentication service hits an error, it is generally returned as part of the redirect URL. We are currently logging this error, but really it should be something that we can bubble up to the user. This is mostly because most of the time we don't have any control over it and the error is specific to that user.

This is tracking the work to somehow bubble up the error message we get back to the user.

Current (initial) thoughts are to add a "more info" link which opens up a popup with the message (as well as the clipper ID/session ID to help debug.

OneNoteApi is not defined in chromePageNavInject.js

This is likely happening on our other page nav inject scripts. This does not seem to affect the operation of the tooltip, so it may be possible that we're referencing the Api somewhere in the script despite us not needing to (I don't see why we should be doing so in the first place). We either need to remove the reference to OneNoteApi or ensure it gets built into the script during build.

Expand the wiki

The wiki currently doesn't cover all the architectural topics of the Web Clipper

Provide a better message for O365 customers who have more than 20k items

We currently do not provide a good-enough message for O365 customers who are unable to save a new page as they reached the 20k item limit in OneDrive. See: https://github.com/OneNoteDev/WebClipper/blob/master/src/scripts/clipperUI/oneNoteApiUtils.ts

This is error code 20008, which we currently handle, but there error message is inadequate. Ideally we can provide a link to some page where the user can take actionable steps to reduce the number of items to < 20000.

Some calls to .innerHTML are throwing an unhandled exception

Relevant App Analytics Query:

reportdata
| where Label == "UnhandledExceptionThrown"
| where ClipperVersion == "3.2.7"
| where FailureInfo contains "innerHTML" 

Not sure what the underlying issue is. Only 2 sessions have hit it, but since we are only rolled out to 5%, this could balloon quickly.

Edge: Unable to preview PDFs

It looks like we are not rendering the PDFs correctly in Edge. Also, the attachment is not getting uploaded properly and the PDF pages are not rendering in OneNote. Basically, things seem to be broken right now.

Enable a way to automatically close the confirmation dialog

This is becoming one of the top requested features based on the more recent reviews. Many customers do not want to have to close the dialog after clipping. We need to think about this a little more, but my first instinct is to make this a setting (which would require a settings panel) and have an option where we automatically close the dialog after X number of seconds. As an enhancement, we might stop the fade-out if the user mouses over the dialog.

KhanAcademy embedded videos are not being extracted

We will likely need to add some KhanAcademy-specific client-side code to manually extract videos from KhanAcademy.

Also, it would be nice if we can have a folder of scripts that does each of these site-specific extractions, one site per file.

Bookmark mode is highlightable

  1. Turn on highlighter in article mode
  2. Switch to bookmark mode
  3. Select some text in the bookmark

Expected: Nothing happens
Actual: That line gets highlighted

Unable to install the extension on Firefox ESR 45.3.0

It looks like the clipper is not able to install on Firefox ESR builds 45.3+. I dug around the documentation and couldn't find anything saying that web extension support isn't yet available, and according to this page, 45.3 is the equivalent to 48 on the standard track, so I think it should work.

Current working theory: We set the minimum Firefox version to 48 and because the ESR builds are on a different versioning track, it's blocking the extension even though technically it should work fine.

Implement safer solution for testing custom settings

PR #22 introduced a setSettingsJsonForTesting method in settings.ts in order to allow for testing of custom, non-production settings. However, exposing a test-only method on Settings like this isn't the best approach, as it could get misused.

Get rid of setSettingsJsonForTesting and implement a DI-like solution so that our test environments can inject a different object than the one in the settings.json production file, as desired.

Implement ratings prompt animations as designed

Joshua spec'd really nice animations for the ratings prompt feature, but due to my own newness to motion design and our animations framework (Velocity.js), implementing them took a while.

We did not want to block shipping the feature, so I reused pre-existing Web Clipper animations to ship. This tracks replacing the temp animations with the shiny new ones.

Casting to <any> should be accompanied with a comment

Yesterday @leakymemory and I found a bug that was a result of casting to , and that code did not have a comment as to why that cast was needed. I think we should look through our code for these occurances and comment these (assuming casting to <any> is something we really need).

Of course, casting to <any> is pretty dangerous in the sense that it goes against what Typescript is for, and where possible, we should create interfaces and use those instead.

Make async/await available to the code base

PR #22 introduced a getCachedValue method on the Storage abstraction in frontEndGlobals.ts. It was created to avoid the asynchronicity of calling getValue inside of the ratings helper feature, which was making ratingsPanel.tsx much less unit testable.

See full discussion.

getCachedValue could be avoided if we could await the completion of some asynchronous tasks before moving on with execution in the calling method.

So this task tracks investigation and work needed to polyfill async/await. Some initial questions:

  1. Do we want to wait for ES8 (ES2017) to (maybe) include it, and for browsers to then support ES8? (caveat: we still need to continue to support IE 10+, which only supports up to ES5)
  2. Is there a reliable npm async/await polyfill module available if we don't wish to upgrade to ES8?

POST Page with a large pdf in <object> tags, followed by that pdf's url in <img> tags renders a second attachment that is 0kb

When attempting to post a page with the following Presentation:

<html xmlns="http://www.w3.org/1999/xhtml" lang=en-US>
<head>
  <title>annual_report_2009.pdf</title>
  <meta name="created" content="-07:00 ">
</head>
<body>
  <object data-attachment="annual_report_2009.pdf" data="name:Attachment8624" type="application/pdf" />
  <img data-render-src="http://www.iso.org/iso/annual_report_2009.pdf"/>
  Clipped from: <a href="http://www.iso.org/iso/annual_report_2009.pdf">http://www.iso.org/iso/annual_report_2009.pdf</a>
</body>
</html>

Expected: Page consisting of pdf attachment, 0 or more images of the pdf, "Clipped from" annotation
Actual: Page consisting of pdf attachment, another pdf attachment (0kb, created by the API, doesn't work), "Clipped from" annotation

Unify mockStorage objects in tests

PR #22 comment from @VishaalK:

We have 3-ish versions of mockStorage out there. I see one in tooltipHelper_tests.ts, another in sectionPicker_tests.ts. Can you add a low pri PBI to unify these?

(Firefox) The default context menu item is appearing on selections' and images' context menus

  1. In Firefox, select some text and right click, or right click an image

Expected: The default context menu item 'OneNote Web Clipper' is not in the context menu
Actual: The default context menu item is there

(from VishaalK): According to https://bugzilla.mozilla.org/show_bug.cgi?id=1274860 this is a known bug and someone was working on it in July. It was updated on 8/10. Not sure if Mozilla employees are going to fix this or if its left for someone else to do. I posted a comment asking for an update.

Reduce and/or eliminate use of `.innerHTML = ` in the code

To get into the Mozilla Add-ons Store, we need to reduce our use of this as it is a potential security issue.

There are 5 places in the code where we do this:

  1. logPageModifications(...) in saveToOneNote.ts: we create a DIV in the document and put clipperState.augmentationPreviewInfo.previewBodyHtml in to determine how many highlights are in the text. It is pretty tedious to determine this information in memory, Also previewBodyHtml is a big ol' string that needs to be converted to HTML in order for this work.
    Update: Shouldn't matter if we sanitize HTML.
  2. createPostProcessedHtml(...) sticks previewBodyHtml into a div so we can apply the font-size and font-family in the preview as in-line styles. Same issue as above.
    Update: Shouldn't matter if we sanitize HTML.
  3. removeElementsNotSupportedInOnml(...) in domUtil.ts. We replace the <center> tag with a div with the same innerHTML. Interesting StackOverflow: http://stackoverflow.com/questions/3435871/jquery-how-to-change-tag-name. A common theme is using an already existing node and traversing it using the DOM APIs.
    Update: Shouldn't matter if we sanitize HTML, we can do it with sanitize-html.
  4. getDocumentFromDomString(...) in domUtils.ts. Used in the bookmark mode to get the content of the page.
    Update: We use this function retrieve img, meta, and link tags from the original, non-augmented contentData of the page. If possible, we could get it from the augmentation result, which is guaranteed to be cleaned. We are rendering the contentData into a document on our iframe, which could be potentially malicious.
  5. When we use Selection mode from the Context menu, we wrap whatever they've selected in a div. We convert a RangyRange into a string by calling .toHtml(). Maybe we can walk the RangyRange instead?
    Update: this one is the most difficult one, but I think we can actually find a way to wrap this using pure JS.

I've identified ways we can sanitize the HTML before injecting it anywhere, but it might not be necessary.

The "outstanding" issue is that we get ContentInHtml from our Augmentation API and then put that in the preview. That comes back as a string, so we have to parse that at some point.

Create a StorageBase wrapper that does sanity checks for setters

For example, we should not set Notebooks in localStorage if UserInfo is not set, and we should abstract this problem away from the developer having to do this check every time.

This one will need a bit of thinking. Was originally going to write a wrapper for storageBase, however, the logic where we know if the user is signed in or not lives in the UI, whereas storageBase lives in the background. I think a possible way of solving this is having two classes that implement some interface representing storage, one of them living in the UI and one in the back. Need to think about this one more as one is synchronous (background -> itself) in nature and the other is asynchronous (UI -> background).

The class itself is a bit of a mess (e.g., getFreshValue is not very relevant to the class, storageBase is a silly name) so we could break it up a bit :)

When we hit errors, they are recorded/counted many times

In looking through the logs, particularly when we hit an unexpected failure, we are logging in such a way that a single failure can be logged/counted multiple times. This makes it hard to monitor spikes as a small number of errors can seem more magnified.

Session_Id == "127f0021-947d-0efa-474d-fb9cb50e952a" as an example.

Utils.ts should be refactored

Utils.ts is an awkward dumping ground for methods that don't belong anywhere else. It also references a bunch of random things like ClipperState etc. That means that code that use Utils.ts to do something really simple will inadvertently import a bunch of other js files. We should split this out in a way that makes sense.

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.