Commit Graph

1062 Commits (35e9417e8fc55c445a9c93eac18092956474e076)
 

Author SHA1 Message Date
Deathamns 03af075a64 Move MutationObserver shim
Since it will be used only for older Safari versions, move it to Safari
related code, so it doesn't pollute the content scripts.
10 years ago
Deathamns ef30ab4c2d Respect `defer` attribute when mirroring 10 years ago
Deathamns abb13424b4 Call XHR.open even if the request will be blocked
Without calling it an error may be thrown if other XHR parameters are set.
10 years ago
Deathamns d9c9627758 Only top window should have type `main_frame` 10 years ago
Deathamns 8f0172467a Remove unnecessary messaging workaround
A better fix was introduced in e36c702 for this issue.

The actual problem was that Safari when sends a message from the
background to content, then it passes to all the frames in the target tab,
but it doesn't make copies, it passes only references to the same object,
so if one frame modifies the message, then other frames would have
received the modified message.
10 years ago
Deathamns aebfb15aa2 Building extension files
Adds possibility to build extension files (Chrome and Safari) from
command line.

To run from the project directory:
python tools/build.py [meta]

If the optional `meta` argument is set, then only the manifest and
language files are uptated.
Without that everything is being built (extension files too) into the
`dist/build/version_number` folder.

For Chrome there will be two files, a crx, and a .zip file which
includes the key.pem private key (so this must not be shared,
it's just a bit help for publishing it to the Chrome Web Store).

Beside the extension files, update-files are generated too (for self
hosting - Safari needs it).
10 years ago
Deathamns a39572448d Fix messaging for Safari 10 years ago
Deathamns 08247fb5dd Preferences button for Safari
Brings back the possibility to click a checkbox which opens the extension
settings from Safari's Preferences/Extensions.
10 years ago
Deathamns 1a38523875 Messaging fixes
Checking the message name (and connectorId) is mandatory for Safari,
because when the background page sends a response back to a document,
then all the frames in its owner tab will receive the exact same
message, which could confuse the script in some cases.
10 years ago
Deathamns 0bc67a8819 Drop js-loader, updates from gorhill/uBlock/master 10 years ago
Deathamns d150eb6d1c Use different page navigation detection for Safari
The beforeNavigate event wasn't reliable (sometimes didn't fire, sometimes
fired unnecessary when opening a link with the middle click - which had a
workaround previously, but that's also removed by this commit).

When the event didn't fire, the bindTabToPageStats method didn't run,
and the requests related to the tab weren't blocked.
10 years ago
Deathamns ed1e23cfb1 Site-patching possibility for Safari
Safari's extension API doesn't provide a way to intercept requests
initiated by plugins, so those cases need special care (or at least the
popular sites).

This commit adds a new JS file (sitepatch-safari.js), which will store the
patches (if it's possible to create one) for specific sites.

As an example, this commit includes a technique for removing in-video ads
from YouTube videos.
10 years ago
Deathamns 192053ae99 document.head isn't always available in Safari 10 years ago
Deathamns 4df265b15f Badge number sometimes disappeared in Safari 10 years ago
Deathamns bc980a3522 Implement pop-up blocking for Safari
It works similarly to the xhr intercepting, except here the window.open
global function is being overridden.
Note that it could only work if the site's Content Security Policy allows
inline scripts, and the script on the webpage doesn't have a copy of the
original window.open function (it can happen only if the page has an
inline script in its head element, where the reference to the original
function can be obtained - likely this cannot be prevented in Safari).
10 years ago
Deathamns 9313a7f16b Element picker tweaks
- Indentation whitespace fixes.
- Use built-in getBoundingClientRect() function instead of self-made.
- Use built-in DOM API for manipulating the class attributes instead of
  altering the className property.
- Add pointer-events: none to the svgRoot when using
  document.elementFromPoint(), but if the browser (older Safari for
  example) doesn't take the pointer-events into account, then fall back to
  display: none.
- Initiate every part of the picker at the same time; when the message is
  received from the background. This way the selected element will have
  the red overlay immediately, instead of showing first the black overlay,
  then a few milliseconds later the red.
10 years ago
Deathamns c56d3ca717 Avoid using Chrome's @@bidi_* type i18n messages
... for the sake of portability.

When including vapi-common.js in an HTML file, then the body element there
will have a "dir" attribute filled with the current locale's direction
(ltr or rtl).

The following languages are considered right-to-left: ar, he, fa, ps, ur.
Everything else is left-to-right.

After the "dir" attribute is set, we can decide in CSS which elements
should have different styling for rtl languages (e.g., body[dir=rtl] #id).
10 years ago
Deathamns f514bf0835 Workaround for a messaging bug in Safari 10 years ago
Deathamns 5d08b448b0 Use HTML5 download instead of extension API
Benefits:
- Cross browser solution (however only for relatively new browsers)
- Doesn't need extra permission in Chrome

If the browser doesn't suppor the download attribute, then a new tab will
be opened with the exported data.

Other changes:
- Start the download only if the data is not empty (previously the
  download started anyway)
- Reorder code in vapi-client.js for Safari, so unnecessary code doesn't
  run on extension pages
10 years ago
Deathamns 34e1df3218 Script injection, element picker, messaging
- Add script injection to vAPI, plus a raw implementation for Safari
  (element-picker.js requires it)
- Tweak element picker to work with Safari
- Revert a change from previous commit: element-picker.js' background
  message handler (since actually it can have its own messaging channel)
- Don't send "undefined" reponses from background to content
10 years ago
Deathamns 4072264fa8 Add .jshintrc, and use the "use strict" directive
.jshintrc's otion-set is a personal choice, merely a suggestion.
Beside that, it includes some common globals for specific browsers, so
there's no need to set the globals in every .js file.

In order to force strict coding, "use strict" directive was added into
every .js file.
10 years ago
Deathamns a04a788eea Work on vendor API abstraction, and near complete Safari support 10 years ago
gorhill ef67930454 refactored tabs/context code 10 years ago
YFdyh000 01df7aa50a Correct issue links 10 years ago
gorhill 88feb450cc new switch: toggle cosmetic filtering on/off for a site 10 years ago
gorhill 12fcc2d4f3 this fixes #1128 10 years ago
gorhill ce549b283a this fixes #1013, #1062 (draft) 10 years ago
gorhill 607c977da2 to catch slow popups 10 years ago
gorhill 49f6504f58 code review 10 years ago
gorhill 415857c55b code review: floating net requests recategorized as behind-the-scene 10 years ago
gorhill 58c546ae08 #1051: test only root frames 10 years ago
gorhill 6ef4821b73 this fixes #510 10 years ago
Deathamns d1f5a78ca2 Chrome: fix tab/window focusing issues
- Opening a tab from incognito window didn't focus the target window
- Previously active tab was visible for a brief moment when an already
  opened tab was selected from another window
10 years ago
gorhill df27e666a7 code review re #118 10 years ago
Deathamns 390733affe Chrome: don't open an Options tab for each window 10 years ago
Deathamns 04a2486ca9 Remove unnecessary fallback code for downloading 10 years ago
gorhill 58793e4d7c this helps #993 10 years ago
gorhill 806d89e443 this fixes #967 10 years ago
Deathamns 193b469ffe Trailing whitespace 10 years ago
gorhill b5e7c9cd03 code review 10 years ago
gorhill ca8d24fb08 this fixes #862 10 years ago
gorhill 754aa6cd8b move profiling code to platform-specific 10 years ago
gorhill 6123bff635 link to relevant jsperf 10 years ago
gorhill b66683a581 avoid closures when processing messages 10 years ago
gorhill 184aec1409 code review 10 years ago
gorhill a0de897608 code review: jshint'ed 10 years ago
gorhill d50594e7eb this fixes #536 10 years ago
gorhill 529258de44 started work on #105, #475, and possibly #510 10 years ago
gorhill f4a853c611 this fixes one part of #498 10 years ago
Deathamns 14950c0c5f Code styling 10 years ago