diff --git a/README.md b/README.md index 2de5419..c05038a 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ -Blocks the Page Visibility API with some prototype hacking. - -Available as a Chrome Extension [here](https://chrome.google.com/webstore/detail/dont-make-me-watch/ahjofnjojbnikkffhagdddimbcmcphhh). +Stops pages from detecting when the user has switched tabs/windows. + +Available as a Chrome Extension [here](https://chrome.google.com/webstore/detail/dont-make-me-watch/ahjofnjojbnikkffhagdddimbcmcphhh). diff --git a/dont.js b/dont.js index 8e9a671..d930bfc 100644 --- a/dont.js +++ b/dont.js @@ -1,5 +1,19 @@ -var c='(function(){var a=Node.prototype.addEventListener;Node.prototype.addEventListener=function(e){if(e=="visibilitychange"||e=="webkitvisibilitychange"){}else a.apply(this,arguments)}})()' - , E=document.documentElement; -E.setAttribute('onreset', c); -E.dispatchEvent(new CustomEvent('reset')); -E.removeAttribute('onreset'); \ No newline at end of file +// Copyright 2018 Navin Francis +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +for (event_name of ["visibilitychange", "webkitvisibilitychange", "blur"]) { + window.addEventListener(event_name, function(event) { + event.stopImmediatePropagation(); + }, true); +} diff --git a/dont.zip b/dont.zip deleted file mode 100644 index dc908c1..0000000 Binary files a/dont.zip and /dev/null differ diff --git a/manifest.json b/manifest.json index dd41c33..62685b9 100644 --- a/manifest.json +++ b/manifest.json @@ -7,8 +7,9 @@ "content_scripts": [ { "matches": ["*://*/*"], + "all_frames": true, "js":["dont.js"], "run_at":"document_start" } ] -} \ No newline at end of file +}