├── .gitignore ├── LICENSE ├── README.md ├── _locales ├── en │ └── messages.json └── zh_TW │ └── messages.json ├── css ├── maximizeVideo.css ├── options.css └── ytb.css ├── icon ├── icon.svg ├── icon_b.svg └── icon_w.svg ├── js ├── background.js ├── content-script.js ├── options.js └── ytb.js ├── manifest.json └── options.html /.gitignore: -------------------------------------------------------------------------------- 1 | # OS generated files # 2 | ###################### 3 | */.DS_Store 4 | .DS_Store 5 | .DS_Store? 6 | ._* 7 | .Spotlight-V100 8 | .Trashes 9 | Icon? 10 | ehthumbs.db 11 | Thumbs.db 12 | 13 | # Packages # 14 | ############ 15 | # it's better to unpack these files and commit the raw source 16 | # git has its own built in compression methods 17 | *.xpi 18 | *.zip 19 | web-ext-artifacts 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Mozilla Public License Version 2.0 2 | ================================== 3 | 4 | 1. Definitions 5 | -------------- 6 | 7 | 1.1. "Contributor" 8 | means each individual or legal entity that creates, contributes to 9 | the creation of, or owns Covered Software. 10 | 11 | 1.2. "Contributor Version" 12 | means the combination of the Contributions of others (if any) used 13 | by a Contributor and that particular Contributor's Contribution. 14 | 15 | 1.3. "Contribution" 16 | means Covered Software of a particular Contributor. 17 | 18 | 1.4. "Covered Software" 19 | means Source Code Form to which the initial Contributor has attached 20 | the notice in Exhibit A, the Executable Form of such Source Code 21 | Form, and Modifications of such Source Code Form, in each case 22 | including portions thereof. 23 | 24 | 1.5. "Incompatible With Secondary Licenses" 25 | means 26 | 27 | (a) that the initial Contributor has attached the notice described 28 | in Exhibit B to the Covered Software; or 29 | 30 | (b) that the Covered Software was made available under the terms of 31 | version 1.1 or earlier of the License, but not also under the 32 | terms of a Secondary License. 33 | 34 | 1.6. "Executable Form" 35 | means any form of the work other than Source Code Form. 36 | 37 | 1.7. "Larger Work" 38 | means a work that combines Covered Software with other material, in 39 | a separate file or files, that is not Covered Software. 40 | 41 | 1.8. "License" 42 | means this document. 43 | 44 | 1.9. "Licensable" 45 | means having the right to grant, to the maximum extent possible, 46 | whether at the time of the initial grant or subsequently, any and 47 | all of the rights conveyed by this License. 48 | 49 | 1.10. "Modifications" 50 | means any of the following: 51 | 52 | (a) any file in Source Code Form that results from an addition to, 53 | deletion from, or modification of the contents of Covered 54 | Software; or 55 | 56 | (b) any new file in Source Code Form that contains any Covered 57 | Software. 58 | 59 | 1.11. "Patent Claims" of a Contributor 60 | means any patent claim(s), including without limitation, method, 61 | process, and apparatus claims, in any patent Licensable by such 62 | Contributor that would be infringed, but for the grant of the 63 | License, by the making, using, selling, offering for sale, having 64 | made, import, or transfer of either its Contributions or its 65 | Contributor Version. 66 | 67 | 1.12. "Secondary License" 68 | means either the GNU General Public License, Version 2.0, the GNU 69 | Lesser General Public License, Version 2.1, the GNU Affero General 70 | Public License, Version 3.0, or any later versions of those 71 | licenses. 72 | 73 | 1.13. "Source Code Form" 74 | means the form of the work preferred for making modifications. 75 | 76 | 1.14. "You" (or "Your") 77 | means an individual or a legal entity exercising rights under this 78 | License. For legal entities, "You" includes any entity that 79 | controls, is controlled by, or is under common control with You. For 80 | purposes of this definition, "control" means (a) the power, direct 81 | or indirect, to cause the direction or management of such entity, 82 | whether by contract or otherwise, or (b) ownership of more than 83 | fifty percent (50%) of the outstanding shares or beneficial 84 | ownership of such entity. 85 | 86 | 2. License Grants and Conditions 87 | -------------------------------- 88 | 89 | 2.1. Grants 90 | 91 | Each Contributor hereby grants You a world-wide, royalty-free, 92 | non-exclusive license: 93 | 94 | (a) under intellectual property rights (other than patent or trademark) 95 | Licensable by such Contributor to use, reproduce, make available, 96 | modify, display, perform, distribute, and otherwise exploit its 97 | Contributions, either on an unmodified basis, with Modifications, or 98 | as part of a Larger Work; and 99 | 100 | (b) under Patent Claims of such Contributor to make, use, sell, offer 101 | for sale, have made, import, and otherwise transfer either its 102 | Contributions or its Contributor Version. 103 | 104 | 2.2. Effective Date 105 | 106 | The licenses granted in Section 2.1 with respect to any Contribution 107 | become effective for each Contribution on the date the Contributor first 108 | distributes such Contribution. 109 | 110 | 2.3. Limitations on Grant Scope 111 | 112 | The licenses granted in this Section 2 are the only rights granted under 113 | this License. No additional rights or licenses will be implied from the 114 | distribution or licensing of Covered Software under this License. 115 | Notwithstanding Section 2.1(b) above, no patent license is granted by a 116 | Contributor: 117 | 118 | (a) for any code that a Contributor has removed from Covered Software; 119 | or 120 | 121 | (b) for infringements caused by: (i) Your and any other third party's 122 | modifications of Covered Software, or (ii) the combination of its 123 | Contributions with other software (except as part of its Contributor 124 | Version); or 125 | 126 | (c) under Patent Claims infringed by Covered Software in the absence of 127 | its Contributions. 128 | 129 | This License does not grant any rights in the trademarks, service marks, 130 | or logos of any Contributor (except as may be necessary to comply with 131 | the notice requirements in Section 3.4). 132 | 133 | 2.4. Subsequent Licenses 134 | 135 | No Contributor makes additional grants as a result of Your choice to 136 | distribute the Covered Software under a subsequent version of this 137 | License (see Section 10.2) or under the terms of a Secondary License (if 138 | permitted under the terms of Section 3.3). 139 | 140 | 2.5. Representation 141 | 142 | Each Contributor represents that the Contributor believes its 143 | Contributions are its original creation(s) or it has sufficient rights 144 | to grant the rights to its Contributions conveyed by this License. 145 | 146 | 2.6. Fair Use 147 | 148 | This License is not intended to limit any rights You have under 149 | applicable copyright doctrines of fair use, fair dealing, or other 150 | equivalents. 151 | 152 | 2.7. Conditions 153 | 154 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted 155 | in Section 2.1. 156 | 157 | 3. Responsibilities 158 | ------------------- 159 | 160 | 3.1. Distribution of Source Form 161 | 162 | All distribution of Covered Software in Source Code Form, including any 163 | Modifications that You create or to which You contribute, must be under 164 | the terms of this License. You must inform recipients that the Source 165 | Code Form of the Covered Software is governed by the terms of this 166 | License, and how they can obtain a copy of this License. You may not 167 | attempt to alter or restrict the recipients' rights in the Source Code 168 | Form. 169 | 170 | 3.2. Distribution of Executable Form 171 | 172 | If You distribute Covered Software in Executable Form then: 173 | 174 | (a) such Covered Software must also be made available in Source Code 175 | Form, as described in Section 3.1, and You must inform recipients of 176 | the Executable Form how they can obtain a copy of such Source Code 177 | Form by reasonable means in a timely manner, at a charge no more 178 | than the cost of distribution to the recipient; and 179 | 180 | (b) You may distribute such Executable Form under the terms of this 181 | License, or sublicense it under different terms, provided that the 182 | license for the Executable Form does not attempt to limit or alter 183 | the recipients' rights in the Source Code Form under this License. 184 | 185 | 3.3. Distribution of a Larger Work 186 | 187 | You may create and distribute a Larger Work under terms of Your choice, 188 | provided that You also comply with the requirements of this License for 189 | the Covered Software. If the Larger Work is a combination of Covered 190 | Software with a work governed by one or more Secondary Licenses, and the 191 | Covered Software is not Incompatible With Secondary Licenses, this 192 | License permits You to additionally distribute such Covered Software 193 | under the terms of such Secondary License(s), so that the recipient of 194 | the Larger Work may, at their option, further distribute the Covered 195 | Software under the terms of either this License or such Secondary 196 | License(s). 197 | 198 | 3.4. Notices 199 | 200 | You may not remove or alter the substance of any license notices 201 | (including copyright notices, patent notices, disclaimers of warranty, 202 | or limitations of liability) contained within the Source Code Form of 203 | the Covered Software, except that You may alter any license notices to 204 | the extent required to remedy known factual inaccuracies. 205 | 206 | 3.5. Application of Additional Terms 207 | 208 | You may choose to offer, and to charge a fee for, warranty, support, 209 | indemnity or liability obligations to one or more recipients of Covered 210 | Software. However, You may do so only on Your own behalf, and not on 211 | behalf of any Contributor. You must make it absolutely clear that any 212 | such warranty, support, indemnity, or liability obligation is offered by 213 | You alone, and You hereby agree to indemnify every Contributor for any 214 | liability incurred by such Contributor as a result of warranty, support, 215 | indemnity or liability terms You offer. You may include additional 216 | disclaimers of warranty and limitations of liability specific to any 217 | jurisdiction. 218 | 219 | 4. Inability to Comply Due to Statute or Regulation 220 | --------------------------------------------------- 221 | 222 | If it is impossible for You to comply with any of the terms of this 223 | License with respect to some or all of the Covered Software due to 224 | statute, judicial order, or regulation then You must: (a) comply with 225 | the terms of this License to the maximum extent possible; and (b) 226 | describe the limitations and the code they affect. Such description must 227 | be placed in a text file included with all distributions of the Covered 228 | Software under this License. Except to the extent prohibited by statute 229 | or regulation, such description must be sufficiently detailed for a 230 | recipient of ordinary skill to be able to understand it. 231 | 232 | 5. Termination 233 | -------------- 234 | 235 | 5.1. The rights granted under this License will terminate automatically 236 | if You fail to comply with any of its terms. However, if You become 237 | compliant, then the rights granted under this License from a particular 238 | Contributor are reinstated (a) provisionally, unless and until such 239 | Contributor explicitly and finally terminates Your grants, and (b) on an 240 | ongoing basis, if such Contributor fails to notify You of the 241 | non-compliance by some reasonable means prior to 60 days after You have 242 | come back into compliance. Moreover, Your grants from a particular 243 | Contributor are reinstated on an ongoing basis if such Contributor 244 | notifies You of the non-compliance by some reasonable means, this is the 245 | first time You have received notice of non-compliance with this License 246 | from such Contributor, and You become compliant prior to 30 days after 247 | Your receipt of the notice. 248 | 249 | 5.2. If You initiate litigation against any entity by asserting a patent 250 | infringement claim (excluding declaratory judgment actions, 251 | counter-claims, and cross-claims) alleging that a Contributor Version 252 | directly or indirectly infringes any patent, then the rights granted to 253 | You by any and all Contributors for the Covered Software under Section 254 | 2.1 of this License shall terminate. 255 | 256 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all 257 | end user license agreements (excluding distributors and resellers) which 258 | have been validly granted by You or Your distributors under this License 259 | prior to termination shall survive termination. 260 | 261 | ************************************************************************ 262 | * * 263 | * 6. Disclaimer of Warranty * 264 | * ------------------------- * 265 | * * 266 | * Covered Software is provided under this License on an "as is" * 267 | * basis, without warranty of any kind, either expressed, implied, or * 268 | * statutory, including, without limitation, warranties that the * 269 | * Covered Software is free of defects, merchantable, fit for a * 270 | * particular purpose or non-infringing. The entire risk as to the * 271 | * quality and performance of the Covered Software is with You. * 272 | * Should any Covered Software prove defective in any respect, You * 273 | * (not any Contributor) assume the cost of any necessary servicing, * 274 | * repair, or correction. This disclaimer of warranty constitutes an * 275 | * essential part of this License. No use of any Covered Software is * 276 | * authorized under this License except under this disclaimer. * 277 | * * 278 | ************************************************************************ 279 | 280 | ************************************************************************ 281 | * * 282 | * 7. Limitation of Liability * 283 | * -------------------------- * 284 | * * 285 | * Under no circumstances and under no legal theory, whether tort * 286 | * (including negligence), contract, or otherwise, shall any * 287 | * Contributor, or anyone who distributes Covered Software as * 288 | * permitted above, be liable to You for any direct, indirect, * 289 | * special, incidental, or consequential damages of any character * 290 | * including, without limitation, damages for lost profits, loss of * 291 | * goodwill, work stoppage, computer failure or malfunction, or any * 292 | * and all other commercial damages or losses, even if such party * 293 | * shall have been informed of the possibility of such damages. This * 294 | * limitation of liability shall not apply to liability for death or * 295 | * personal injury resulting from such party's negligence to the * 296 | * extent applicable law prohibits such limitation. Some * 297 | * jurisdictions do not allow the exclusion or limitation of * 298 | * incidental or consequential damages, so this exclusion and * 299 | * limitation may not apply to You. * 300 | * * 301 | ************************************************************************ 302 | 303 | 8. Litigation 304 | ------------- 305 | 306 | Any litigation relating to this License may be brought only in the 307 | courts of a jurisdiction where the defendant maintains its principal 308 | place of business and such litigation shall be governed by laws of that 309 | jurisdiction, without reference to its conflict-of-law provisions. 310 | Nothing in this Section shall prevent a party's ability to bring 311 | cross-claims or counter-claims. 312 | 313 | 9. Miscellaneous 314 | ---------------- 315 | 316 | This License represents the complete agreement concerning the subject 317 | matter hereof. If any provision of this License is held to be 318 | unenforceable, such provision shall be reformed only to the extent 319 | necessary to make it enforceable. Any law or regulation which provides 320 | that the language of a contract shall be construed against the drafter 321 | shall not be used to construe this License against a Contributor. 322 | 323 | 10. Versions of the License 324 | --------------------------- 325 | 326 | 10.1. New Versions 327 | 328 | Mozilla Foundation is the license steward. Except as provided in Section 329 | 10.3, no one other than the license steward has the right to modify or 330 | publish new versions of this License. Each version will be given a 331 | distinguishing version number. 332 | 333 | 10.2. Effect of New Versions 334 | 335 | You may distribute the Covered Software under the terms of the version 336 | of the License under which You originally received the Covered Software, 337 | or under the terms of any subsequent version published by the license 338 | steward. 339 | 340 | 10.3. Modified Versions 341 | 342 | If you create software not governed by this License, and you want to 343 | create a new license for such software, you may create and use a 344 | modified version of this License if you rename the license and remove 345 | any references to the name of the license steward (except to note that 346 | such modified license differs from this License). 347 | 348 | 10.4. Distributing Source Code Form that is Incompatible With Secondary 349 | Licenses 350 | 351 | If You choose to distribute Source Code Form that is Incompatible With 352 | Secondary Licenses under the terms of this version of the License, the 353 | notice described in Exhibit B of this License must be attached. 354 | 355 | Exhibit A - Source Code Form License Notice 356 | ------------------------------------------- 357 | 358 | This Source Code Form is subject to the terms of the Mozilla Public 359 | License, v. 2.0. If a copy of the MPL was not distributed with this 360 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 361 | 362 | If it is not possible or desirable to put the notice in a particular 363 | file, then You may include the notice in a location (such as a LICENSE 364 | file in a relevant directory) where a recipient would be likely to look 365 | for such a notice. 366 | 367 | You may add additional accurate notices of copyright ownership. 368 | 369 | Exhibit B - "Incompatible With Secondary Licenses" Notice 370 | --------------------------------------------------------- 371 | 372 | This Source Code Form is "Incompatible With Secondary Licenses", as 373 | defined by the Mozilla Public License, v. 2.0. 374 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MaximizeVideo 2 | Firefox add-on Maximize HTML5/Flash video and fill current tab. 3 | 4 | * Install Firefox add-on: [addons.mozilla.org](https://addons.mozilla.org/zh-TW/firefox/addon/maximize-video/) 5 | * Install Chrome extension: [Chrome Web Store](https://chrome.google.com/webstore/detail/maximize-video/bfpkgjlnboeecjmnbhbknmemmckmpomb) 6 | -------------------------------------------------------------------------------- /_locales/en/messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "extName": { 3 | "message": "Maximize Video", 4 | "description": "" 5 | }, 6 | "extDescription": { 7 | "message": "Maximize HTML5/Flash video and fill current tab.", 8 | "description": "" 9 | }, 10 | "optionPageTitle": { 11 | "message": "Maximize Video Preferences:", 12 | "description": "" 13 | }, 14 | "maximizeThisVideo": { 15 | "message": "Maximize this video", 16 | "description": "" 17 | }, 18 | "toolbarAction": { 19 | "message": "Toolbar button action:", 20 | "description": "" 21 | }, 22 | "selectFirstVideo": { 23 | "message": "Auto maximize first video element(If not found any video element in 3 seconds, auto cancel)", 24 | "description": "" 25 | }, 26 | "dontSelectVideo": { 27 | "message": "Manual selct video element", 28 | "description": "" 29 | }, 30 | "supportFlash": { 31 | "message": "Support Flash video", 32 | "description": "" 33 | }, 34 | "ignoreTinyElement": { 35 | "message": "Ignore tiny element:", 36 | "description": "" 37 | }, 38 | "minWidth": { 39 | "message": "Minimum width", 40 | "description": "" 41 | }, 42 | "minHeight": { 43 | "message": "Minimum height", 44 | "description": "" 45 | }, 46 | "popupWindow": { 47 | "message": "After maximize video, pop-up current tab to standalone window", 48 | "description": "" 49 | }, 50 | "needOtherAddon": { 51 | "message": "**You need install another add-on 'Popup Window' to enable this function: ", 52 | "description": "" 53 | }, 54 | "installPopupWindow": { 55 | "message": "https://addons.mozilla.org/firefox/addon/popup-window/", 56 | "description": "" 57 | }, 58 | "delayForHideCursor": { 59 | "message": "When maximize video, auto hide mouse cursor after ", 60 | "description": "" 61 | }, 62 | "delayForHideCursor2": { 63 | "message": " seconds.", 64 | "description": "" 65 | }, 66 | "iconColor": { 67 | "message": "Toolbar button icon color", 68 | "description": "" 69 | }, 70 | "iconColorBlack": { 71 | "message": "Black", 72 | "description": "" 73 | }, 74 | "iconColorWhite": { 75 | "message": "White", 76 | "description": "" 77 | }, 78 | "execute": { 79 | "message": "Maximize video", 80 | "description": "" 81 | }, 82 | "youtubeControllers": { 83 | "message": "Keep original video controls on Youtube", 84 | "description": "" 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /_locales/zh_TW/messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "extName": { 3 | "message": "Maximize Video", 4 | "description": "" 5 | }, 6 | "extDescription": { 7 | "message": "將 HTML5/Flash 影片放到最大,填滿頁面。", 8 | "description": "" 9 | }, 10 | "optionPageTitle": { 11 | "message": "Maximize Video 設定:", 12 | "description": "" 13 | }, 14 | "maximizeThisVideo": { 15 | "message": "將此影片最大化", 16 | "description": "" 17 | }, 18 | "toolbarAction": { 19 | "message": "於工具列啟動後:", 20 | "description": "" 21 | }, 22 | "selectFirstVideo": { 23 | "message": "自動最大化頁面中第一個找到的影片(如果三秒內沒找到任何影片,將自動取消)", 24 | "description": "" 25 | }, 26 | "dontSelectVideo": { 27 | "message": "手動選擇要最大化的影片", 28 | "description": "" 29 | }, 30 | "supportFlash": { 31 | "message": "支援 Flash 影片", 32 | "description": "" 33 | }, 34 | "ignoreTinyElement": { 35 | "message": "忽略小型元素:", 36 | "description": "" 37 | }, 38 | "minWidth": { 39 | "message": "最小寬度", 40 | "description": "" 41 | }, 42 | "minHeight": { 43 | "message": "最小高度", 44 | "description": "" 45 | }, 46 | "popupWindow": { 47 | "message": "影片最大化後自動彈出至獨立視窗", 48 | "description": "" 49 | }, 50 | "needOtherAddon": { 51 | "message": "**要啟用此功能需另外安裝 Popup Window 套件:", 52 | "description": "" 53 | }, 54 | "installPopupWindow": { 55 | "message": "https://addons.mozilla.org/firefox/addon/popup-window/", 56 | "description": "" 57 | }, 58 | "delayForHideCursor": { 59 | "message": "最大化影片後,於", 60 | "description": "" 61 | }, 62 | "delayForHideCursor2": { 63 | "message": "秒後自動隱藏滑鼠游標。", 64 | "description": "" 65 | }, 66 | "iconColor": { 67 | "message": "工具列圖示顏色", 68 | "description": "" 69 | }, 70 | "iconColorBlack": { 71 | "message": "黑", 72 | "description": "" 73 | }, 74 | "iconColorWhite": { 75 | "message": "白", 76 | "description": "" 77 | }, 78 | "execute": { 79 | "message": "影片最大化", 80 | "description": "" 81 | }, 82 | "youtubeControllers": { 83 | "message": "在 Youtube 網站使用原有的播放器控制列", 84 | "description": "" 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /css/maximizeVideo.css: -------------------------------------------------------------------------------- 1 | [mvclass=show] *:not([mvclass=show]):not([mvclass=core]) { 2 | display:none !important; 3 | opacity:0 !important; 4 | visibility: hidden !important; 5 | } 6 | 7 | [mvclass=show-t] >*:not([mvclass=show-t]):not([mvclass=core]) { 8 | display:none !important; 9 | opacity:0 !important; 10 | visibility: hidden !important; 11 | } 12 | 13 | [mvclass=show], 14 | [mvclass=show-t] { 15 | contain:unset !important; 16 | min-width:0px !important; 17 | min-height:0px !important; 18 | width:0px !important; 19 | height:0px !important; 20 | transform: none !important; 21 | -webkit-transform:none !important; 22 | transform-style:flat !important; 23 | -webkit-transform-style:flat !important; 24 | border-width:0px !important; 25 | will-change:auto !important; 26 | mask-image: unset !important; 27 | -webkit-mask-image: unset !important; 28 | container-type: normal !important; 29 | background: none !important; 30 | } 31 | 32 | video[mvclass=core] { 33 | background-color:black; 34 | } 35 | 36 | .controls[mvclass=core], 37 | .hover-display[mvclass=core], 38 | .pl-controls-bottom[mvclass=core], 39 | .player-streamstatus[mvclass=core], 40 | .player-controls-bottom[mvclass=core] { 41 | position: fixed !important; 42 | z-index: 2147483640; 43 | } 44 | 45 | .pl-controls-bottom[mvclass=core]:hover, 46 | .player-controls-bottom[mvclass=core]:hover { 47 | opacity: 1 !important; 48 | } 49 | 50 | .hover-display[mvclass=core] { 51 | width: 100% !important; 52 | } 53 | 54 | .hover-display[mvclass=core]:hover { 55 | opacity: 1 !important; 56 | } 57 | 58 | .hover-display[mvclass=core] .pl-pinned-panel { 59 | display: none !important; 60 | } 61 | 62 | html[mvclass=core], 63 | body[mvclass=show], 64 | body[mvclass=show-t] { 65 | contain:unset !important; 66 | background-color: #000 !important; 67 | position: relative !important; 68 | overflow: hidden !important; 69 | } 70 | 71 | .mvCover { 72 | display: block; 73 | position: fixed; 74 | width: 100%; 75 | height: 100%; 76 | z-index: 2147483641; 77 | background-color: black; 78 | opacity: 0.5; 79 | left: 0; 80 | top: 0; 81 | margin: 0; 82 | padding: 0; 83 | } 84 | 85 | .mvVideoBlock { 86 | display: block; 87 | position:absolute; 88 | z-index: 2147483642; 89 | background-color: red; 90 | opacity: 0.25; 91 | margin: 0; 92 | padding: 0; 93 | } 94 | 95 | .mvVideoBlock.mvHighLevel { 96 | z-index: 2147483643; 97 | } 98 | 99 | .mvVideoBlock:hover { 100 | opacity: 0.5; 101 | } 102 | 103 | [mvclass="show-t"] [data-a-target="player-settings-submenu-advanced-toggle-mini"] { 104 | display:none !important; 105 | } 106 | -------------------------------------------------------------------------------- /css/options.css: -------------------------------------------------------------------------------- 1 | div.col { 2 | vertical-align: top; 3 | display: inline-block; 4 | } 5 | 6 | .itemDiv { 7 | display: block; 8 | margin-top:16px; 9 | } 10 | 11 | .itemLabel { 12 | display: inline-block; 13 | width: 60px; 14 | } 15 | 16 | .delayForHideCursor { 17 | width: 50px; 18 | } 19 | -------------------------------------------------------------------------------- /css/ytb.css: -------------------------------------------------------------------------------- 1 | body.mvytp { 2 | overflow: hidden !important; 3 | } 4 | 5 | body.mvytp .ytp-size-button { 6 | display: none !important; 7 | } 8 | 9 | body.mvytp #movie_player { 10 | position: fixed !important; 11 | /* z-index: 999999999999 !important; */ 12 | z-index: 2100 !important; 13 | bottom: 0px !important; 14 | right: 0px !important; 15 | left: 0px !important; 16 | top: 0px !important; 17 | } 18 | 19 | body.mvytp .html5-video-container { 20 | height: 100% !important; 21 | width: 100% !important; 22 | } 23 | 24 | body.mvytp .html5-video-container .html5-main-video { 25 | height: 100% !important; 26 | width: 100% !important; 27 | bottom: 0px !important; 28 | right: 0px !important; 29 | left: 0px !important; 30 | top: 0px !important; 31 | background: #000 !important; 32 | } 33 | -------------------------------------------------------------------------------- /icon/icon.svg: -------------------------------------------------------------------------------- 1 | 2 | Layer 1 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /icon/icon_b.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /icon/icon_w.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /js/background.js: -------------------------------------------------------------------------------- 1 | let mvTabs = []; 2 | let resetTabs = []; 3 | let selectedVideo = null; 4 | 5 | let defaultPreference = { 6 | popupWindow: false, 7 | toolbarAction: 0, 8 | // supportFlash: true, 9 | minWidth: 100, 10 | minHeight: 100, 11 | autoHideCursor: false, 12 | delayForHideCursor: 5, 13 | iconColor: 0, 14 | youtubeControllers: false, 15 | version: 8 16 | }; 17 | let preferences = {}; 18 | 19 | function getHashCode() { 20 | let hashCode = ''; 21 | let characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; 22 | let max = characters.length; 23 | for(let i = 0; i < 32; ++i) { 24 | let r = Math.floor((Math.random() * (i === 0 ? 52 : 62) )); //don't start with number 25 | //let r = Math.floor(Math.random() * max); 26 | let char = characters.charAt(r); 27 | hashCode += char; 28 | } 29 | return hashCode; 30 | } 31 | 32 | const storageChangeHandler = (changes, area) => { 33 | if(area === 'local') { 34 | let changedItems = Object.keys(changes); 35 | for (let item of changedItems) { 36 | preferences[item] = changes[item].newValue; 37 | switch (item) { 38 | case 'iconColor': 39 | setBrowserActionIcon(); 40 | break; 41 | } 42 | } 43 | } 44 | }; 45 | 46 | const loadPreference = () => { 47 | chrome.storage.local.get(results => { 48 | if ((typeof results.length === 'number') && (results.length > 0)) { 49 | results = results[0]; 50 | } 51 | if (!results.version) { 52 | preferences = defaultPreference; 53 | chrome.storage.local.set(defaultPreference, res => { 54 | chrome.storage.onChanged.addListener(storageChangeHandler); 55 | }); 56 | } else { 57 | preferences = results; 58 | chrome.storage.onChanged.addListener(storageChangeHandler); 59 | } 60 | if (preferences.version !== defaultPreference.version) { 61 | let update = {}; 62 | let needUpdate = false; 63 | for(let p in defaultPreference) { 64 | if(preferences[p] === undefined) { 65 | update[p] = defaultPreference[p]; 66 | needUpdate = true; 67 | } 68 | } 69 | if(needUpdate) { 70 | chrome.storage.local.set(update); 71 | } 72 | } 73 | setBrowserActionIcon(); 74 | }); 75 | }; 76 | 77 | const setBrowserActionIcon = () => { 78 | if(preferences.iconColor === 1) { 79 | chrome.browserAction.setIcon({path: 'icon/icon_w.svg'}); 80 | } else { 81 | chrome.browserAction.setIcon({path: 'icon/icon_b.svg'}); 82 | } 83 | }; 84 | 85 | window.addEventListener('DOMContentLoaded', event => { 86 | loadPreference(); 87 | }); 88 | 89 | chrome.browserAction.disable(); 90 | chrome.browserAction.onClicked.addListener(tab => { 91 | execBrowserAction(tab); 92 | }); 93 | 94 | const execBrowserAction = (tab) => { 95 | if(!['about:addons', 'about:blank'].includes(tab.url)) { 96 | let hashCode = getHashCode(); 97 | chrome.tabs.sendMessage(tab.id, { 98 | action: 'setVideoMask', 99 | toolbarAction: preferences.toolbarAction, 100 | hashCode: hashCode 101 | }); 102 | } 103 | }; 104 | 105 | chrome.tabs.onUpdated.addListener((tabId, changeInfo, tabInfo) => { 106 | if(!['about:addons', 'about:blank'].includes(tabInfo.url)) { 107 | try{ 108 | chrome.tabs.sendMessage(tabId, { 109 | action: 'getReadyStatus' 110 | }, response => { 111 | if(response){ 112 | if(response.readyStatus) { 113 | chrome.browserAction.enable(tabId); 114 | } 115 | else { 116 | chrome.browserAction.disable(tabId); 117 | } 118 | } 119 | }); 120 | } catch(ex){} 121 | } 122 | }); 123 | 124 | chrome.tabs.query({}, tabs => { 125 | for(let tab of tabs) { 126 | if(tab.status === 'loading') { 127 | try { 128 | chrome.tabs.sendMessage(tab.id, { 129 | action: 'getReadyStatus' 130 | }, response => { 131 | if(response && response.readyStatus === true) { 132 | chrome.browserAction.enable(tab.id); 133 | } 134 | }); 135 | } catch(ex) {} 136 | } 137 | else { //complete 138 | chrome.browserAction.enable(tab.id); 139 | } 140 | } 141 | }); 142 | 143 | chrome.commands.onCommand.addListener(command => { 144 | if (command === "maximizeVideo") { 145 | chrome.tabs.query({active: true, currentWindow: true}, tabs => { 146 | if ((typeof tabs !== 'undefined') && (tabs.length > 0)) { 147 | let tab = tabs[0]; 148 | browser.browserAction.isEnabled({tabId: tab.id}).then(result => { 149 | if(result === true) { 150 | execBrowserAction(tab); 151 | } 152 | }); 153 | } 154 | else { 155 | } 156 | }); 157 | } 158 | }); 159 | 160 | const messageHandler = (message, sender, sendResponse) => { 161 | // console.log(message); 162 | if(message.action === 'tabReady'){ 163 | chrome.browserAction.enable(sender.tab.id); 164 | } 165 | else if(message.action === 'execContentScript'){ 166 | chrome.tabs.executeScript(sender.tab.Id, { 167 | file: 'js/content-script.js', 168 | frameId: sender.frameId, 169 | runAt: 'document_end' 170 | }, () => { 171 | chrome.tabs.sendMessage(sender.tab.id, { 172 | action: 'scanVideo', 173 | // supportFlash: message.supportFlash !== undefined ? message.supportFlash : preferences.supportFlash, 174 | minWidth: message.minWidth !== undefined ? message.minWidth : preferences.minWidth, 175 | minHeight: message.minHeight !== undefined ? message.minHeight : preferences.minHeight 176 | }, {frameId: sender.frameId}); 177 | }); 178 | } 179 | else if(message.action === 'popupWindow'){ 180 | if(preferences.popupWindow) { 181 | chrome.runtime.sendMessage('PopupWindow@ettoolong', 182 | { 183 | action: 'popupWindow', 184 | tabId: sender.tab.id 185 | }); 186 | } 187 | } 188 | else if(message.action === 'scanVideo'){ 189 | chrome.tabs.executeScript(sender.tab.Id, { 190 | code: '(function(){if(window !== window.top && !window.selfId) chrome.runtime.sendMessage({action: "execContentScript"})})();', 191 | allFrames: true 192 | }); 193 | chrome.tabs.sendMessage(sender.tab.id, { 194 | action: 'scanVideo', 195 | hashCode: message.hashCode, 196 | // supportFlash: message.supportFlash !== undefined ? message.supportFlash : preferences.supportFlash, 197 | minWidth: message.minWidth !== undefined ? message.minWidth : preferences.minWidth, 198 | minHeight: message.minHeight !== undefined ? message.minHeight : preferences.minHeight 199 | }); 200 | } 201 | else if(message.action === 'cancelSelectMode'){ 202 | chrome.tabs.sendMessage(sender.tab.id, { 203 | action: 'cancelSelectMode' 204 | }); 205 | } 206 | else if(message.action === 'maximizeVideo'){ 207 | const exec = ({youtubeControllers}) => { 208 | chrome.tabs.sendMessage(sender.tab.id, { 209 | action: 'maximizeVideo', 210 | hashCode: message.hashCode, 211 | strict: message.strict, 212 | youtubeControllers 213 | }); 214 | } 215 | 216 | if (preferences.youtubeControllers && message.url.startsWith('https://www.youtube.com/watch')) { 217 | exec({youtubeControllers: true}) 218 | chrome.tabs.sendMessage(sender.tab.id, { 219 | action: 'maximizeVideo-ytb', 220 | }); 221 | } else { 222 | exec({youtubeControllers: false}) 223 | } 224 | } 225 | else if(message.action === 'cancelMaximaMode'){ 226 | const exec = ({youtubeControllers}) => { 227 | chrome.tabs.sendMessage(sender.tab.id, { 228 | action: 'cancelMaximaMode', 229 | youtubeControllers 230 | }); 231 | } 232 | 233 | if (preferences.youtubeControllers && message.url.startsWith('https://www.youtube.com/watch')) { 234 | exec({youtubeControllers: true}) 235 | chrome.tabs.sendMessage(sender.tab.id, { 236 | action: 'cancelMaximaMode-ytb', 237 | }); 238 | } else { 239 | exec({youtubeControllers: false}) 240 | } 241 | } 242 | else if(message.action === 'videoHotkey'){ 243 | chrome.tabs.sendMessage(sender.tab.id, { 244 | action: 'videoHotkey', 245 | keyCode: message.keyCode, 246 | shiftKey: message.shiftKey, 247 | ctrlKey: message.ctrlKey 248 | }); 249 | } 250 | //return true; 251 | }; 252 | 253 | const externalMessageHandler = (message, sender, sendResponse) => { 254 | 255 | // chrome.runtime.sendMessage('MaximizeVideo@ettoolong',{ 256 | // action: 'maximizeVideo', 257 | // autoSelect: true, 258 | // supportFlash: true, 259 | // minWidth: 100, 260 | // minHeight: 100, 261 | // tabId: 0 262 | // }); 263 | 264 | if(message.action === 'maximizeVideo' && message.tabId !== undefined) { 265 | let toolbarAction = preferences.toolbarAction; 266 | let hashCode = getHashCode(); 267 | if(message.autoSelect !== undefined) { 268 | toolbarAction = message.autoSelect === true ? 1 : 0; 269 | } 270 | 271 | chrome.tabs.sendMessage(message.tabId, { 272 | action: 'setVideoMask', 273 | toolbarAction: toolbarAction, 274 | hashCode: hashCode, 275 | // supportFlash: message.supportFlash !== undefined ? message.supportFlash : preferences.supportFlash, 276 | minWidth: message.minWidth !== undefined ? message.minWidth : preferences.minWidth, 277 | minHeight: message.minHeight !== undefined ? message.minHeight : preferences.minHeight 278 | }); 279 | } 280 | }; 281 | 282 | chrome.runtime.onMessage.addListener(messageHandler); 283 | chrome.runtime.onMessageExternal.addListener(externalMessageHandler); 284 | -------------------------------------------------------------------------------- /js/content-script.js: -------------------------------------------------------------------------------- 1 | let currentPrefs = {}; 2 | let init = false; 3 | 4 | const shortcutFuncs = { 5 | toggleCaptions: function(v){ 6 | const validTracks = []; 7 | for(let i = 0; i < v.textTracks.length; ++i){ 8 | const tt = v.textTracks[i]; 9 | if(tt.mode === 'showing'){ 10 | tt.mode = 'disabled'; 11 | if(v.textTracks.addEventListener){ 12 | // If text track event listeners are supported 13 | // (they are on the most recent Chrome), add 14 | // a marker to remember the old track. Use a 15 | // listener to delete it if a different track 16 | // is selected. 17 | v.cbhtml5vsLastCaptionTrack = tt.label; 18 | function cleanup(e){ 19 | for(let i = 0; i < v.textTracks.length; ++i){ 20 | const ott = v.textTracks[i]; 21 | if(ott.mode === 'showing'){ 22 | delete v.cbhtml5vsLastCaptionTrack; 23 | v.textTracks.removeEventListener('change', cleanup); 24 | return; 25 | } 26 | } 27 | } 28 | v.textTracks.addEventListener('change', cleanup); 29 | } 30 | return; 31 | }else if(tt.mode !== 'hidden'){ 32 | validTracks.push(tt); 33 | } 34 | } 35 | // If we got here, none of the tracks were selected. 36 | if(validTracks.length === 0){ 37 | return true; // Do not prevent default if no UI activated 38 | } 39 | // Find the best one and select it. 40 | validTracks.sort(function(a, b){ 41 | 42 | if(v.cbhtml5vsLastCaptionTrack){ 43 | const lastLabel = v.cbhtml5vsLastCaptionTrack; 44 | 45 | if(a.label === lastLabel && b.label !== lastLabel){ 46 | return -1; 47 | }else if(b.label === lastLabel && a.label !== lastLabel){ 48 | return 1; 49 | } 50 | } 51 | 52 | const aLang = a.language.toLowerCase(), 53 | bLang = b.language.toLowerCase(), 54 | navLang = navigator.language.toLowerCase(); 55 | 56 | if(aLang === navLang && bLang !== navLang){ 57 | return -1; 58 | }else if(bLang === navLang && aLang !== navLang){ 59 | return 1; 60 | } 61 | 62 | const aPre = aLang.split('-')[0], 63 | bPre = bLang.split('-')[0], 64 | navPre = navLang.split('-')[0]; 65 | 66 | if(aPre === navPre && bPre !== navPre){ 67 | return -1; 68 | }else if(bPre === navPre && aPre !== navPre){ 69 | return 1; 70 | } 71 | 72 | return 0; 73 | })[0].mode = 'showing'; 74 | }, 75 | 76 | togglePlay: function(v){ 77 | if(v.paused) 78 | v.play(); 79 | else 80 | v.pause(); 81 | }, 82 | 83 | toStart: function(v){ 84 | v.currentTime = 0; 85 | }, 86 | 87 | toEnd: function(v){ 88 | v.currentTime = v.duration; 89 | }, 90 | 91 | skipLeft: function(v,key,shift,ctrl){ 92 | if(shift) 93 | v.currentTime -= 10; 94 | else if(ctrl) 95 | v.currentTime -= 1; 96 | else 97 | v.currentTime -= 5; 98 | }, 99 | 100 | skipRight: function(v,key,shift,ctrl){ 101 | if(shift) 102 | v.currentTime += 10; 103 | else if(ctrl) 104 | v.currentTime += 1; 105 | else 106 | v.currentTime += 5; 107 | }, 108 | 109 | increaseVol: function(v){ 110 | if(v.volume <= 0.9) v.volume += 0.1; 111 | else v.volume = 1; 112 | }, 113 | 114 | decreaseVol: function(v){ 115 | if(v.volume >= 0.1) v.volume -= 0.1; 116 | else v.volume = 0; 117 | }, 118 | 119 | toggleMute: function(v){ 120 | v.muted = !v.muted; 121 | }, 122 | 123 | toggleFS: function(v){ 124 | v.requestFullscreen(); 125 | }, 126 | 127 | slow: function(v,key,shift){ 128 | if(v.playbackRate >= 0.25) v.playbackRate -= 0.25; 129 | else v.playbackRate = 0.01; 130 | }, 131 | 132 | fast: function(v,key,shift){ 133 | v.playbackRate += 0.25; 134 | }, 135 | 136 | normalSpeed: function(v,key,shift){ 137 | v.playbackRate = v.defaultPlaybackRate; 138 | }, 139 | 140 | toPercentage: function(v,key){ 141 | v.currentTime = v.duration * (key - 48) / 10.0; 142 | }, 143 | }; 144 | 145 | const keyFuncs = { 146 | 32 : shortcutFuncs.togglePlay, // Space 147 | 75 : shortcutFuncs.togglePlay, // K 148 | 35 : shortcutFuncs.toEnd, // End 149 | 48 : shortcutFuncs.toStart, // 0 150 | 36 : shortcutFuncs.toStart, // Home 151 | 37 : shortcutFuncs.skipLeft, // Left arrow 152 | 74 : shortcutFuncs.skipLeft, // J 153 | 39 : shortcutFuncs.skipRight, // Right arrow 154 | 76 : shortcutFuncs.skipRight, // L 155 | 38 : shortcutFuncs.increaseVol, // Up arrow 156 | 40 : shortcutFuncs.decreaseVol, // Down arrow 157 | 77 : shortcutFuncs.toggleMute, // M 158 | 70 : shortcutFuncs.toggleFS, // F 159 | 67 : shortcutFuncs.toggleCaptions, // C 160 | 188: shortcutFuncs.slow, // Comma 161 | 190: shortcutFuncs.fast, // Period 162 | 191: shortcutFuncs.normalSpeed, // Forward slash 163 | 49 : shortcutFuncs.toPercentage, // 1 164 | 50 : shortcutFuncs.toPercentage, // 2 165 | 51 : shortcutFuncs.toPercentage, // 3 166 | 52 : shortcutFuncs.toPercentage, // 4 167 | 53 : shortcutFuncs.toPercentage, // 5 168 | 54 : shortcutFuncs.toPercentage, // 6 169 | 55 : shortcutFuncs.toPercentage, // 7 170 | 56 : shortcutFuncs.toPercentage, // 8 171 | 57 : shortcutFuncs.toPercentage, // 9 172 | }; 173 | 174 | const srcProxy = { 175 | 'bleacherreport.com': { 176 | play: (node) => { 177 | let elem = node.parentNode.parentNode.querySelector('.amp-interactive'); 178 | elem.click(); 179 | } 180 | } 181 | } 182 | 183 | const setMiniPlayer = (impl, disable) => { 184 | const settingsButton = document.querySelector('[data-a-target="player-settings-button"]'); 185 | try { 186 | settingsButton.click(); 187 | document.querySelector('[data-a-target="player-settings-menu-item-advanced"]').click(); 188 | const menuItem = document.querySelector('[data-a-target="player-settings-submenu-advanced-toggle-mini"]'); 189 | const input = menuItem.querySelector('input'); 190 | if (disable) { 191 | if (input.checked) { 192 | impl.miniPlayer = true; 193 | input.click(); 194 | } 195 | } else { 196 | if (!!impl.miniPlayer && !input.checked) { 197 | input.click(); 198 | } 199 | } 200 | } catch (e) { 201 | } finally { 202 | settingsButton.click(); 203 | } 204 | } 205 | 206 | function MVUniversal() {} 207 | MVUniversal.prototype={ 208 | topTags: [], 209 | mvClass: 'show', 210 | setCoreNode: function () { 211 | }, 212 | restoreCoreNode: function () { 213 | }, 214 | getMainNode: function (node) { 215 | return node; 216 | }, 217 | setControllers: function (show) { 218 | let node = this.selectedNode; 219 | let tagName = node.tagName.toLocaleLowerCase(); 220 | if(tagName === 'video' || tagName === 'iframe') { 221 | let attribute = tagName === 'video' ? 'controls' : 'allowfullscreen'; 222 | if(show) { 223 | this.original[attribute] = node.hasAttribute(attribute) ? node.getAttribute(attribute) : null; 224 | node.setAttribute(attribute, 'true'); 225 | } 226 | let script = document.createElement('script'); 227 | script.setAttribute('id','mvScript'); 228 | script.textContent = '(function(){Object.defineProperty(document.querySelector("video[mvHashCode='+this.currentHashCode+']"), "'+attribute+'", {configurable: false});document.head.removeChild(document.getElementById("mvScript"));})()'; 229 | document.head.appendChild(script); 230 | if(!show) { 231 | if(this.original[attribute] !== null) 232 | node.setAttribute(attribute, this.original[attribute]); 233 | else 234 | node.removeAttribute(attribute); 235 | } 236 | } 237 | }, 238 | registerEvents: function(node) { 239 | if(!node.hasAttribute('mvEventReg')) { 240 | node.setAttribute('mvEventReg', 'true'); 241 | node.addEventListener('click', event => { 242 | if(this.status === 'maximaVideo') 243 | event.stopImmediatePropagation(); 244 | }, true); 245 | node.addEventListener('mousedown', event => { 246 | if(this.status === 'maximaVideo') 247 | event.stopImmediatePropagation(); 248 | }, true); 249 | node.addEventListener('mouseup', event => { 250 | if(this.status === 'maximaVideo') 251 | event.stopImmediatePropagation(); 252 | }, true); 253 | node.addEventListener('play', event => { 254 | if (!node.src) { 255 | let proxy = srcProxy[window.location.host] 256 | if (proxy) { 257 | event.preventDefault(); 258 | proxy.play(node); 259 | } 260 | } 261 | }, true); 262 | } 263 | } 264 | } 265 | 266 | function MVTwitch() {} 267 | MVTwitch.prototype={ 268 | topTags: ['body', 'html'], 269 | mvClass: 'show-t', 270 | setCoreNode: function () { 271 | let coreNode = document.querySelector('.player-controls'); 272 | coreNode.parentNode.setAttribute('mvclass', 'core'); 273 | coreNode.setAttribute('mvclass', 'core'); 274 | setMiniPlayer(this, true); 275 | }, 276 | restoreCoreNode: function () { 277 | setMiniPlayer(this, false); 278 | }, 279 | getMainNode: function (node) { 280 | return document.querySelector('.video-player__container'); 281 | }, 282 | setControllers: function (show, node) { 283 | }, 284 | registerEvents: function () { 285 | } 286 | } 287 | 288 | function MVETwitch() {} 289 | MVETwitch.prototype={ 290 | topTags: ['body', 'html'], 291 | mvClass: 'show-t', 292 | setCoreNode: function () { 293 | let controlsNode = document.querySelector('.pl-controls-bottom'); 294 | controlsNode.setAttribute('mvclass', 'core'); 295 | controlsNode.parentNode.setAttribute('mvclass', 'core'); 296 | let hoverDisplay = document.querySelector('.hover-display'); 297 | hoverDisplay.setAttribute('mvclass', 'core'); 298 | let playerui = document.querySelector('.player-ui'); 299 | if(playerui) { 300 | playerui.setAttribute('mvclass', 'core'); 301 | } 302 | }, 303 | restoreCoreNode: function () { 304 | }, 305 | getMainNode: function (node) { 306 | return node; 307 | }, 308 | setControllers: function (show, node) { 309 | }, 310 | registerEvents: function () { 311 | } 312 | } 313 | 314 | function MVNetflix() {} 315 | MVNetflix.prototype={ 316 | topTags: ['body', 'html'], 317 | mvClass: 'show-t', 318 | setCoreNode: function () { 319 | document.querySelector('.controls').setAttribute('mvclass', 'core'); 320 | }, 321 | restoreCoreNode: function () { 322 | }, 323 | getMainNode: function (node) { 324 | return node; 325 | }, 326 | setControllers: function (show, node) { 327 | }, 328 | registerEvents: function () { 329 | } 330 | } 331 | 332 | const HASHCODE_LENGTH = 32; 333 | let mvImpl; 334 | let idCount = 0; 335 | let vnStyle = [ 336 | 'position:fixed !important;', 337 | 'top:0 !important;', 338 | 'left:0 !important;', 339 | 'min-width:100vw !important;', 340 | 'min-height:100vh !important;', 341 | 'width:100vw !important;', 342 | 'height:100vh !important;', 343 | 'max-width:100vw !important;', 344 | 'max-height:100vh !important;', 345 | 'margin:0 !important;', 346 | 'padding:0 !important;', 347 | 'transform:none !important;', 348 | 'visibility:visible !important;', 349 | 'border-width:0 !important;', 350 | 'cursor:default !important;', 351 | 'object-fit:contain !important;', 352 | 'z-index: 2147483639 !important;', 353 | ].join(''); 354 | let vnStyleList = [ 355 | 'position', 'top', 'left', 'min-width', 356 | 'min-height', 'width', 'height', 357 | 'max-width', 'max-height', 'margin', 358 | 'padding', 'visibility', 'border-width', 359 | 'cursor']; 360 | 361 | if(window.location.href.startsWith('https://www.twitch.tv/')) { 362 | mvImpl = new MVTwitch(); 363 | } 364 | else if(window.location.href.startsWith('https://player.twitch.tv/')) { 365 | mvImpl = new MVETwitch(); 366 | } 367 | else if(window.location.href.startsWith('https://www.netflix.com/')) { 368 | mvImpl = new MVNetflix(); 369 | } 370 | else { 371 | mvImpl = new MVUniversal(); 372 | } 373 | mvImpl.status = 'normal'; 374 | mvImpl.original = {}; 375 | mvImpl.updateTimer = null; 376 | 377 | function getHashCode(length) { 378 | let hashCode = ''; 379 | let characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; 380 | let max = characters.length; 381 | for(let i = 0; i < length; ++i) { 382 | let r = Math.floor((Math.random() * (i === 0 ? 52 : 62) )); //don't start with number 383 | //let r = Math.floor(Math.random() * max); 384 | let char = characters.charAt(r); 385 | hashCode += char; 386 | } 387 | return hashCode; 388 | } 389 | let selfId = getHashCode(HASHCODE_LENGTH); 390 | window.selfId = selfId; 391 | 392 | function isYoutubeEmbed () { 393 | return window.location.href.startsWith('https://www.youtube.com/embed/'); 394 | } 395 | function isYoutubeWatch () { 396 | return window.location.href.startsWith('https://www.youtube.com/watch'); 397 | } 398 | 399 | function addToMvCover (elemInfo) { 400 | // console.log('[addToMvCover] ' + JSON.stringify(elemInfo, null, 4)); 401 | // console.log(new Date()); 402 | let diffTime = 0; 403 | let allBlock = []; 404 | diffTime = new Date() - mvImpl.startScanTime; 405 | 406 | if(mvImpl.status !== 'selectVideo') 407 | return; 408 | let cover = document.querySelector('.mvCover'); 409 | let videoBlocks = document.querySelectorAll('.mvVideoBlock'); 410 | //let videoBlocks = document.querySelectorAll('.mvVideoBlock'); 411 | 412 | let bodyPosition = window.getComputedStyle(document.body,null).getPropertyValue('position'); 413 | let found = false; 414 | for(let v of videoBlocks) { 415 | let h = v.getAttribute('mvMaskHash'); 416 | if(h === elemInfo.hashCode) { 417 | //update 418 | v.style.left = elemInfo.left + 'px'; 419 | v.style.top = elemInfo.top + 'px'; 420 | v.style.width = elemInfo.width + 'px'; 421 | v.style.height = elemInfo.height + 'px'; 422 | v.style.display = elemInfo.visible ? 'block' : 'none'; 423 | found = true; 424 | break; 425 | } 426 | } 427 | if(!found) { 428 | let videoBlock = document.createElement('DIV'); 429 | videoBlock.classList.add('mvVideoBlock'); 430 | if(elemInfo.source) 431 | videoBlock.classList.add('mvHighLevel'); 432 | videoBlock.setAttribute('tn', elemInfo.tagName); 433 | videoBlock.style.left = elemInfo.left + 'px'; 434 | videoBlock.style.top = elemInfo.top + 'px'; 435 | videoBlock.style.width = elemInfo.width + 'px'; 436 | videoBlock.style.height = elemInfo.height + 'px'; 437 | videoBlock.setAttribute('mvMaskHash', elemInfo.hashCode); 438 | //videoBlock.textContent = elemInfo.hashCode; 439 | videoBlock.addEventListener('mousedown', event => { 440 | if(event.button === 0) { 441 | event.stopImmediatePropagation(); 442 | event.preventDefault(); 443 | let msg = {action: 'maximizeVideo', url: window.location.href, hashCode: elemInfo.hashCode}; 444 | try{ 445 | if(event.shiftKey && event.layerX < 10 && event.layerY < 10 ) msg.strict = true; 446 | } catch (ex){} 447 | chrome.runtime.sendMessage(msg); 448 | } 449 | },true); 450 | document.body.appendChild(videoBlock); 451 | videoBlock.style.position = bodyPosition==='fixed' ? 'fixed' : 'absolute'; 452 | videoBlock.style.display = elemInfo.visible ? 'block' : 'none'; 453 | allBlock.push(videoBlock); 454 | } 455 | 456 | for(let v of videoBlocks) { 457 | v.style.position = bodyPosition==='fixed' ? 'fixed' : 'absolute'; 458 | allBlock.push(v); 459 | } 460 | 461 | if(mvImpl.toolbarAction === 1 && diffTime > 600) { 462 | let selected = null; 463 | for(let v of videoBlocks) { 464 | if(!selected) { 465 | selected = v; 466 | } 467 | else { 468 | if(parseInt(v.style.width) * parseInt(v.style.height) > parseInt(selected.style.width) * parseInt(selected.style.height)) { 469 | selected = v; 470 | } 471 | } 472 | } 473 | if(selected) { 474 | mvImpl.toolbarAction = 0; 475 | chrome.runtime.sendMessage({action: 'maximizeVideo', url: window.location.href, hashCode: selected.getAttribute('mvMaskHash')}); 476 | } 477 | } 478 | } 479 | 480 | function lockMainNodeStyle(lock) { 481 | if(lock) { 482 | if(mvImpl.strict) { 483 | //no way to unlock. 484 | let script = document.createElement('script'); 485 | script.setAttribute('id','mvLockScript'); 486 | script.textContent = '(function(){Object.defineProperty(document.querySelector("[mvHashCode='+mvImpl.currentHashCode+']"), "style", {configurable: false});document.head.removeChild(document.getElementById("mvLockScript"));})()'; 487 | document.head.appendChild(script); 488 | } 489 | else { 490 | let observer = new MutationObserver(function(mutations) { 491 | mutations.forEach(function(mutation) { 492 | let n = mutation.target; 493 | let currentStyle = n.getAttribute('style'); 494 | if(currentStyle !== mvImpl.vnNewStyle) { 495 | n.setAttribute('style', mvImpl.vnNewStyle); 496 | } 497 | }); 498 | }); 499 | let config = { attributes: true, attributeFilter: ['style']}; 500 | observer.observe(mvImpl.mainNode, config); 501 | mvImpl.mainNodeObserver = observer; 502 | } 503 | } 504 | else { 505 | if(mvImpl.mainNodeObserver) { 506 | mvImpl.mainNodeObserver.disconnect(); 507 | mvImpl.mainNodeObserver = null; 508 | } 509 | } 510 | } 511 | 512 | function maximizeMainNode() { 513 | let originalStyle = mvImpl.originalStyle = (mvImpl.mainNode.getAttribute('style') || ''); 514 | let fixedStyle = vnStyle; 515 | let fixedStyleList = [...vnStyleList] 516 | let vnNewStyle = ''; 517 | originalStyle = originalStyle.trim().replace(/\r\n/g, '\r').replace(/\n/g, '\r').replace(/\r/g, ''); 518 | if (originalStyle === '') { 519 | vnNewStyle = fixedStyle; 520 | } 521 | else { 522 | let styles = originalStyle.split(';'); 523 | let slist = []; 524 | for (let s of styles) { 525 | let t = /([a-zA-Z-]{2,})\s?:\s?(.+)/; 526 | if(t.test(s)) { 527 | let m = s.split(t); 528 | let key = m[1]; 529 | let value = m[2]; 530 | if (!fixedStyleList.includes(key)) { 531 | slist.push(key+':'+value); 532 | } 533 | } 534 | } 535 | if (slist.length === 0) { 536 | vnNewStyle = fixedStyle; 537 | } 538 | else { 539 | vnNewStyle = fixedStyle + slist.join(';')+';'; 540 | } 541 | } 542 | mvImpl.vnNewStyle = vnNewStyle; 543 | mvImpl.mainNode.setAttribute('style', vnNewStyle); 544 | lockMainNodeStyle(true); 545 | }; 546 | 547 | function restoreVideo() { 548 | if (!mvImpl.selectedNode) return; 549 | if (!mvImpl.youtubeControllers || (!isYoutubeEmbed() && !isYoutubeWatch())) { 550 | mvImpl.setControllers(false); 551 | } 552 | lockMainNodeStyle(false); 553 | mvImpl.mainNode.setAttribute('style', mvImpl.originalStyle); 554 | 555 | let mvClassList = [mvImpl.mvClass, 'core']; 556 | for(let cn of mvClassList) { 557 | let nodes = document.querySelectorAll('[mvclass='+cn+']'); 558 | for(let node of nodes) { 559 | node.removeAttribute('mvclass'); 560 | } 561 | } 562 | 563 | if(mvImpl.scrollPosition) { 564 | window.scrollTo(mvImpl.scrollPosition.x, mvImpl.scrollPosition.y); 565 | } 566 | }; 567 | 568 | function maximizeVideo(selectedNode, chain = []) { 569 | const _chain = [...chain] 570 | 571 | mvImpl.scrollPosition = { x: window.scrollX, y: window.scrollY }; 572 | 573 | const hideAllSibling = (node) => { 574 | if(node === mvImpl.mainNode) { 575 | node.setAttribute('mvclass', 'core'); 576 | } 577 | else{ // if(node !== mvImpl.mainNode) { 578 | node.setAttribute('mvclass', mvImpl.mvClass); 579 | } 580 | 581 | let parent = node.parentNode; 582 | if(parent) { 583 | if (parent.nodeType === Node.ELEMENT_NODE ) { 584 | if(!mvImpl.topTags.includes(parent.tagName.toLocaleLowerCase())) { 585 | hideAllSibling(parent); 586 | } 587 | } else if (parent.nodeType === Node.DOCUMENT_FRAGMENT_NODE) { 588 | if (_chain.length) { 589 | parent = _chain.pop() 590 | hideAllSibling(parent); 591 | } 592 | } 593 | } 594 | }; 595 | 596 | mvImpl.selectedNode = selectedNode; 597 | if (!mvImpl.youtubeControllers || (!isYoutubeEmbed() && !isYoutubeWatch())) { 598 | mvImpl.setControllers(true); 599 | } 600 | mvImpl.mainNode = mvImpl.getMainNode(selectedNode); 601 | if(window !== window.top) { //this video is in iframe 602 | window.parent.postMessage({action: 'getId', senderId: selfId, nextAction: 'setVideoNode'},'*'); 603 | } 604 | mvImpl.registerEvents(mvImpl.mainNode); 605 | if (!mvImpl.youtubeControllers || (!isYoutubeEmbed() && !isYoutubeWatch())) { 606 | hideAllSibling(mvImpl.mainNode); 607 | } 608 | maximizeMainNode(); 609 | } 610 | 611 | function getChildIFrameById(id) { 612 | let iframes = document.getElementsByTagName('IFRAME'); 613 | for(let iframe of iframes) { 614 | if(iframe.getAttribute('mv_iframe') === id) { 615 | return iframe; 616 | } 617 | } 618 | } 619 | 620 | window.addEventListener('message', e => { 621 | if (e.data.action === 'getId') { //message from child 622 | let iframes = document.getElementsByTagName('IFRAME'); 623 | for(let iframe of iframes) { 624 | let vmi = iframe.getAttribute('mv_iframe'); 625 | if(!vmi) { 626 | iframe.setAttribute('mv_iframe', idCount); 627 | iframe.setAttribute('allowfullscreen', 'true'); 628 | iframe.contentWindow.postMessage({action: 'setId', reciver: e.data.senderId, id: iframe.getAttribute('mv_iframe'), nextAction: e.data.nextAction, extDate: e.data.extDate}, '*'); 629 | idCount++; 630 | } 631 | else if(vmi) { 632 | iframe.contentWindow.postMessage({action: 'setId', reciver: e.data.senderId, id: iframe.getAttribute('mv_iframe'), nextAction: e.data.nextAction, extDate: e.data.extDate}, '*'); 633 | } 634 | } 635 | } 636 | else if (e.data.action === 'setId') { //message from parent 637 | if(e.data.reciver !== selfId) { 638 | return; 639 | } 640 | if(e.data.nextAction === 'setVideoNode') { 641 | if(mvImpl.mainNode && window !== window.top) { 642 | window.parent.postMessage({action: 'setVideoNode', id: e.data.id},'*'); 643 | } 644 | } 645 | else if(e.data.nextAction === 'addVideoElements') { 646 | window.parent.postMessage({action: 'addVideoElements', id: e.data.id, elemInfos: e.data.extDate},'*'); 647 | } 648 | } 649 | else if(e.data.action === 'setVideoNode'){ //message from child 650 | let iframe = getChildIFrameById(e.data.id); 651 | let hashCode = iframe.getAttribute('mvHashCode'); 652 | if(!hashCode) { 653 | hashCode = getHashCode(HASHCODE_LENGTH); 654 | iframe.setAttribute('mvHashCode', hashCode); 655 | } 656 | mvImpl.currentHashCode = hashCode; 657 | maximizeVideo(iframe); 658 | // if(window !== window.top) { 659 | // window.parent.postMessage({action: 'getId', senderId: selfId, nextAction: 'setVideoNode'},'*'); 660 | // } 661 | } 662 | else if(e.data.action === 'addVideoElements'){ //message from child 663 | let iframe = getChildIFrameById(e.data.id); 664 | let iframeRect = iframe.getBoundingClientRect(); 665 | if(window !== window.top) { 666 | for(let elemInfo of e.data.elemInfos) { 667 | elemInfo.left += iframeRect.left + window.scrollX; 668 | elemInfo.top += iframeRect.top + window.scrollY; 669 | } 670 | window.parent.postMessage({action: 'getId', senderId: selfId, nextAction: 'addVideoElements', extDate: e.data.elemInfos},'*'); 671 | } 672 | else { 673 | for(let elemInfo of e.data.elemInfos) { 674 | elemInfo.left += iframeRect.left + window.scrollX; 675 | elemInfo.top += iframeRect.top + window.scrollY; 676 | addToMvCover(elemInfo); 677 | } 678 | } 679 | } 680 | }); 681 | 682 | window.addEventListener('keydown', event => { 683 | if(event.key === 'Escape' && mvImpl.status === 'selectVideo') { 684 | chrome.runtime.sendMessage({action: 'cancelSelectMode'}); 685 | } else if (mvImpl.status === 'maximaVideo') { 686 | if (event.altKey || event.metaKey || event.ctrlKey) { 687 | return true; 688 | } 689 | const func = keyFuncs[event.keyCode]; 690 | if(func){ 691 | //send message to background script ! 692 | //func(mvImpl.mainNode, event.keyCode, event.shiftKey, event.ctrlKey); 693 | if(event.keyCode === 70) {// fullscreen 694 | mvImpl.mainNode.requestFullscreen(); 695 | } 696 | else { 697 | let msg = {action: 'videoHotkey', keyCode: event.keyCode, shiftKey: event.shiftKey, ctrlKey: event.ctrlKey}; 698 | chrome.runtime.sendMessage(msg); 699 | } 700 | event.preventDefault(); 701 | event.stopPropagation(); 702 | event.stopImmediatePropagation(); 703 | return false; 704 | } 705 | return true; 706 | } 707 | }, true); 708 | 709 | const handleKeyEvent = (event) => { 710 | if (mvImpl.status === 'maximaVideo') { 711 | if(event.altKey || event.metaKey){ 712 | return true; 713 | } 714 | const func = keyFuncs[event.keyCode]; 715 | if(func){ 716 | event.preventDefault(); 717 | event.stopPropagation(); 718 | event.stopImmediatePropagation(); 719 | return false; 720 | } 721 | return true; 722 | } 723 | } 724 | window.addEventListener('keypress', handleKeyEvent, true); 725 | window.addEventListener('keyup', handleKeyEvent, true); 726 | window.addEventListener('DOMContentLoaded', event => { 727 | document.addEventListener('fullscreenchange', event => { 728 | if (mvImpl.status === 'maximaVideo' && !mvImpl.youtubeControllers && !mvImpl instanceof MVTwitch && !mvImpl instanceof MVETwitch) { 729 | event.stopPropagation(); 730 | event.stopImmediatePropagation(); 731 | } 732 | }, true); 733 | }); 734 | 735 | function inRect(point, rect) { 736 | return (point.x > rect.left && point.x < rect.right && 737 | point.y > rect.top && point.y < rect.bottom); 738 | } 739 | 740 | function intersectRect(r1, r2) { 741 | return !(r2.left > r1.right || 742 | r2.right < r1.left || 743 | r2.top > r1.bottom || 744 | r2.bottom < r1.top); 745 | } 746 | 747 | function isVisible(elem, elemRect) { 748 | const style = getComputedStyle(elem); 749 | if (style.display === 'none') return false; 750 | if (style.visibility !== 'visible') return false; 751 | if (style.opacity < 0.1) return false; 752 | let r = {left:0, top:0, right: window.innerWidth, bottom: window.innerHeight}; 753 | if(intersectRect(r, elemRect)) { 754 | return true; 755 | } 756 | else { 757 | return false; 758 | } 759 | } 760 | 761 | function getElemInfo(elem) { 762 | let elemRect = elem.getBoundingClientRect(); 763 | if(isYoutubeEmbed() && !elem.src) { 764 | let newElemRect = { 765 | bottom: elemRect.bottom, 766 | height: elemRect.height, 767 | left: elemRect.left, 768 | right: elemRect.right, 769 | top: elemRect.top, 770 | width: elemRect.width, 771 | x: elemRect.x, 772 | y: elemRect.y 773 | }; 774 | elemRect = newElemRect; 775 | elemRect.y = elemRect.top = 0; 776 | elemRect.bottom = elemRect.height; 777 | } 778 | let hashCode = elem.getAttribute('mvHashCode'); 779 | let foundSource = false; 780 | if(!hashCode) { 781 | hashCode = getHashCode(HASHCODE_LENGTH); 782 | elem.setAttribute('mvHashCode', hashCode); 783 | } 784 | 785 | if(elem.getAttribute('src')) { 786 | foundSource = true; 787 | } 788 | else { 789 | if(elem.querySelector('source[src]')) { 790 | foundSource = true; 791 | } 792 | } 793 | return { 794 | tagName: elem.tagName.toLocaleLowerCase(), 795 | left: elemRect.left + window.scrollX, 796 | top: elemRect.top + window.scrollY, 797 | width: elemRect.width, 798 | height: elemRect.height, 799 | hashCode: hashCode, 800 | source: foundSource, 801 | visible: isVisible(elem, elemRect), 802 | path: [] 803 | }; 804 | } 805 | 806 | function uploadElemInfo(elements, minWidth, minHeight, onlyUpdateNewElem) { 807 | let elemInfos = []; 808 | for(let elem of elements) { 809 | let mvHashCode = elem.getAttribute('mvHashCode'); 810 | if(onlyUpdateNewElem && mvHashCode) 811 | continue; 812 | let elemInfo = getElemInfo(elem); 813 | if(elemInfo.width >= minWidth && elemInfo.height >= minHeight) { 814 | if(window === window.top) { 815 | addToMvCover(elemInfo); 816 | } 817 | else { 818 | elemInfos.push(elemInfo); 819 | } 820 | } 821 | } 822 | if(window !== window.top && elemInfos.length) { 823 | window.parent.postMessage({action: 'getId', senderId: selfId, nextAction: 'addVideoElements', extDate: elemInfos},'*'); 824 | } 825 | } 826 | 827 | function removeVideoMask() { 828 | if(window === window.top) { 829 | let elem = document.querySelector('.mvCover'); 830 | if(elem) 831 | elem.parentNode.removeChild(elem); 832 | let videoBlocks = document.querySelectorAll('.mvVideoBlock'); 833 | for(let v of videoBlocks) { 834 | v.parentNode.removeChild(v); 835 | } 836 | } 837 | } 838 | 839 | function clearHideCursorTimer() { 840 | if(mvImpl.hideCursorTimer) { 841 | clearTimeout(mvImpl.hideCursorTimer); 842 | mvImpl.hideCursorTimer = null; 843 | } 844 | } 845 | 846 | function setHideCursorTimer() { 847 | clearHideCursorTimer(); 848 | if(currentPrefs.autoHideCursor) { 849 | mvImpl.hideCursorTimer = setTimeout(()=>{ 850 | mvImpl.vnNewStyle = mvImpl.vnNewStyle.replace('cursor:default','cursor:none'); 851 | mvImpl.mainNode.setAttribute('style', mvImpl.vnNewStyle); 852 | 853 | mvImpl.mainNode.addEventListener('mousemove', e => { 854 | mvImpl.vnNewStyle = mvImpl.vnNewStyle.replace('cursor:none','cursor:default'); 855 | mvImpl.mainNode.setAttribute('style', mvImpl.vnNewStyle); 856 | setHideCursorTimer(); 857 | }, {capture: true, once: true}); // FF50+, Ch55+ 858 | }, currentPrefs.delayForHideCursor*1000); 859 | } 860 | } 861 | 862 | 863 | function findVideoElements(selector) { 864 | const elements = [] 865 | 866 | document.querySelectorAll(selector).forEach(element => { 867 | elements.push(element) 868 | }) 869 | 870 | const shadowRoots = [] 871 | const _findShadowRoots = (root) => { 872 | root.querySelectorAll('*').forEach(element => { 873 | // No shadow root? Continue. 874 | if (!element.shadowRoot) { 875 | return 876 | } 877 | shadowRoots.push(element) 878 | _findShadowRoots(element.shadowRoot) 879 | }) 880 | } 881 | _findShadowRoots(document) 882 | if (shadowRoots.length) { 883 | for(const e of shadowRoots) { 884 | const v = e.shadowRoot.querySelector(selector) 885 | if (v) { 886 | elements.push(v) 887 | } 888 | } 889 | } 890 | return elements 891 | } 892 | 893 | function findVideoElement(selector) { 894 | const videoElem = document.querySelector(selector) 895 | if (videoElem) { 896 | return { elem: videoElem, chain: []} 897 | } 898 | 899 | const _findShadowRoots = (root, chain) => { 900 | let res = { elem: null, chain: chain} 901 | root.querySelectorAll('*').forEach(element => { 902 | // No shadow root? Continue. 903 | if (!element.shadowRoot) { 904 | return 905 | } 906 | if (!element.querySelector('#shadowStyle')) { 907 | const shadowStyle = document.createElement('style'); 908 | shadowStyle.setAttribute('id', 'shadowStyle') 909 | shadowStyle.textContent = ` 910 | :host([mvclass=show]) *:not([mvclass=show]):not([mvclass=core]) { 911 | display:none !important; 912 | opacity:0 !important; 913 | visibility: hidden !important; 914 | } 915 | `; 916 | element.appendChild(shadowStyle); 917 | } 918 | const e = element.shadowRoot.querySelector(selector) 919 | if (e) { 920 | res = {elem: e, chain: [ ...chain, element ]} 921 | } else { 922 | const res2 = _findShadowRoots(element.shadowRoot, [ ...chain, element ]) 923 | if (res2.elem) { 924 | res = res2 925 | } 926 | } 927 | }) 928 | return res 929 | } 930 | const res = _findShadowRoots(document, []) 931 | return res 932 | } 933 | 934 | chrome.runtime.onMessage.addListener( (message, sender, sendResponse) => { 935 | if(message.action === 'videoHotkey') { 936 | if(mvImpl.mainNode.tagName === 'VIDEO') { 937 | const func = keyFuncs[message.keyCode]; 938 | func(mvImpl.mainNode, message.keyCode, message.shiftKey, message.ctrlKey); 939 | } 940 | } 941 | else if(message.action === 'maximizeVideo') { 942 | if(mvImpl.status === 'maximaVideo') 943 | return; 944 | mvImpl.status = 'maximaVideo'; 945 | removeVideoMask(); 946 | let elements = document.querySelectorAll('video'); 947 | for(let v of elements) { 948 | if(v.getAttribute('mvHashCode') !== message.hashCode) 949 | v.pause(); 950 | } 951 | 952 | let { elem, chain } = findVideoElement('video[mvHashCode="'+message.hashCode+'"]') 953 | if(elem) { 954 | initPrefs( ()=>{ 955 | setHideCursorTimer(); 956 | }); 957 | mvImpl.setCoreNode(); 958 | mvImpl.currentHashCode = message.hashCode; 959 | mvImpl.youtubeControllers = message.youtubeControllers; 960 | if(isYoutubeEmbed() && !elem.src) { 961 | elem.click(); 962 | elem.addEventListener('progress', ()=>{ 963 | elem.pause(); 964 | },{capture: true, once: true}); 965 | } 966 | mvImpl.strict = message.strict; 967 | maximizeVideo(elem, chain); 968 | if(mvImpl.mainNode.tagName === 'VIDEO') { 969 | mvImpl.mainNode.focus({preventScroll:true}); 970 | } 971 | chrome.runtime.sendMessage({action: 'popupWindow'}); 972 | } 973 | } 974 | else if(message.action === 'getReadyStatus') { 975 | if(window === window.top) { 976 | if (document.readyState === 'complete' || document.readyState === 'interactive'){ 977 | sendResponse({readyStatus: true}); 978 | } 979 | else { 980 | sendResponse({readyStatus: false}); 981 | } 982 | } 983 | } 984 | else if(message.action === 'setVideoMask') { 985 | if(window === window.top) { 986 | if(mvImpl.status === 'normal') { 987 | mvImpl.toolbarAction = message.toolbarAction; 988 | // console.log('setVideoMask'); 989 | // console.log(new Date()); 990 | removeVideoMask(); 991 | if (document.readyState === 'complete' || document.readyState === 'interactive') { 992 | mvImpl.startScanTime = new Date(); 993 | let cover = document.createElement('DIV'); 994 | cover.classList.add('mvCover'); 995 | cover.setAttribute('mvMaskHash', message.hashCode); 996 | document.body.appendChild(cover); 997 | let msg = {action: 'scanVideo', hashCode: message.hashCode}; 998 | // if(message.supportFlash !== undefined) msg.supportFlash = message.supportFlash; 999 | if(message.minWidth !== undefined) msg.minWidth = message.minWidth; 1000 | if(message.minHeight !== undefined) msg.minHeight = message.minHeight; 1001 | chrome.runtime.sendMessage(msg); 1002 | } 1003 | } 1004 | else if(mvImpl.status === 'selectVideo') { 1005 | chrome.runtime.sendMessage({action: 'cancelSelectMode'}); 1006 | } 1007 | else if(mvImpl.status === 'maximaVideo') { 1008 | clearHideCursorTimer(); 1009 | chrome.runtime.sendMessage({action: 'cancelMaximaMode', url: window.location.href}); 1010 | } 1011 | } 1012 | } 1013 | else if(message.action === 'scanVideo') { 1014 | mvImpl.status = 'selectVideo'; 1015 | // console.log('scanVideo'); 1016 | const selector = 'video'; 1017 | let elements = findVideoElements(selector) 1018 | const _uploadElemInfo = () => { 1019 | mvImpl.scanVideoTimer = null; 1020 | if(mvImpl.status === 'selectVideo'){ 1021 | uploadElemInfo(elements, message.minWidth, message.minHeight ); 1022 | elements = findVideoElements(selector); 1023 | uploadElemInfo(elements, message.minWidth, message.minHeight, true); 1024 | mvImpl.scanVideoTimer = setTimeout(_uploadElemInfo, 200); 1025 | } 1026 | if(window === window.top && mvImpl.toolbarAction === 1) { 1027 | let diffTime = new Date() - mvImpl.startScanTime; 1028 | if(diffTime > 3000) { 1029 | mvImpl.toolbarAction = 0; 1030 | chrome.runtime.sendMessage({action: 'cancelSelectMode'}); 1031 | } 1032 | } 1033 | } 1034 | _uploadElemInfo(); 1035 | } 1036 | else if(message.action === 'cancelSelectMode') { 1037 | mvImpl.status = 'normal'; 1038 | removeVideoMask(); 1039 | } 1040 | else if(message.action === 'cancelMaximaMode') { 1041 | mvImpl.status = 'normal'; 1042 | mvImpl.restoreCoreNode(); 1043 | restoreVideo(); 1044 | } 1045 | return false; 1046 | }); 1047 | 1048 | if(window === window.top) { 1049 | if (document.readyState === 'complete' || document.readyState === 'interactive') { 1050 | chrome.runtime.sendMessage({action: 'tabReady'}); 1051 | } 1052 | else { 1053 | window.addEventListener('DOMContentLoaded', event => { 1054 | chrome.runtime.sendMessage({action: 'tabReady'}); 1055 | }, true); 1056 | } 1057 | } 1058 | 1059 | function initPrefs(cb){ 1060 | if(!init) { 1061 | init = true; 1062 | chrome.storage.local.get(results => { 1063 | if ((typeof results.length === 'number') && (results.length > 0)) { 1064 | results = results[0]; 1065 | } 1066 | currentPrefs = results; 1067 | cb(); 1068 | }); 1069 | 1070 | chrome.storage.onChanged.addListener((changes, area) => { 1071 | if(area === 'local') { 1072 | let changedItems = Object.keys(changes); 1073 | for (let item of changedItems) { 1074 | currentPrefs[item] = changes[item].newValue; 1075 | switch (item) { 1076 | case 'autoHideCursor': 1077 | case 'delayForHideCursor': 1078 | if(mvImpl.status === 'maximaVideo') { 1079 | setHideCursorTimer(); 1080 | } 1081 | break; 1082 | } 1083 | } 1084 | } 1085 | }); 1086 | } 1087 | else { 1088 | cb(); 1089 | } 1090 | } 1091 | -------------------------------------------------------------------------------- /js/options.js: -------------------------------------------------------------------------------- 1 | let currentPrefs = {}; 2 | 3 | const saveToPreference = (id, value) => { 4 | let update = {}; 5 | update[id] = value; 6 | chrome.storage.local.set(update); 7 | }; 8 | 9 | const handleVelueChange = id => { 10 | let elem = document.getElementById(id); 11 | if(elem) { 12 | let elemType = elem.getAttribute('type'); 13 | if(elemType === 'checkbox') { 14 | elem.addEventListener('input', event => { 15 | saveToPreference(id, elem.checked ? true : false); 16 | }); 17 | } 18 | else if(elemType === 'number') { 19 | elem.addEventListener('input', event => { 20 | saveToPreference(id, parseInt(elem.value)); 21 | }); 22 | } 23 | else if(elemType === 'option') { 24 | elem.addEventListener('input', event => { 25 | saveToPreference(id, parseInt(elem.value)); 26 | }); 27 | } 28 | else if(elemType === 'radioGroup') { 29 | let radios = Array.from(elem.querySelectorAll('input[name='+id+']')); 30 | for(let radio of radios) { 31 | radio.addEventListener('input', event => { 32 | if(radio.checked) 33 | saveToPreference(id, parseInt(radio.getAttribute('value'))); 34 | }); 35 | } 36 | } 37 | } 38 | }; 39 | 40 | const setValueToElem = (id, value) => { 41 | let elem = document.getElementById(id); 42 | if(elem) { 43 | let elemType = elem.getAttribute('type'); 44 | if(elemType === 'checkbox') { 45 | elem.checked = value; 46 | } 47 | if(elemType === 'number') { 48 | elem.value = value; 49 | } 50 | else if(elemType === 'option') { 51 | let options = Array.from(elem.querySelectorAll('option')); 52 | for(let option of options) { 53 | if(parseInt(option.getAttribute('value')) === value) { 54 | option.selected = true; 55 | break; 56 | } 57 | } 58 | } 59 | else if(elemType === 'radioGroup') { 60 | let radios = Array.from(elem.querySelectorAll('input[name='+id+']')); 61 | for(let radio of radios) { 62 | if(parseInt(radio.getAttribute('value')) === value) { 63 | radio.checked = true; 64 | break; 65 | } 66 | } 67 | } 68 | } 69 | }; 70 | 71 | const init = preferences => { 72 | currentPrefs = preferences; 73 | for(let p in preferences) { 74 | setValueToElem(p, preferences[p]); 75 | handleVelueChange(p); 76 | } 77 | let l10nTags = Array.from(document.querySelectorAll('[data-l10n-id]')); 78 | l10nTags.forEach(tag => { 79 | tag.textContent = chrome.i18n.getMessage(tag.getAttribute('data-l10n-id')); 80 | }); 81 | }; 82 | 83 | window.addEventListener('load', event => { 84 | chrome.storage.local.get(results => { 85 | if ((typeof results.length === 'number') && (results.length > 0)) { 86 | results = results[0]; 87 | } 88 | if (results.version) { 89 | init(results); 90 | } 91 | }); 92 | }, true); 93 | -------------------------------------------------------------------------------- /js/ytb.js: -------------------------------------------------------------------------------- 1 | chrome.runtime.onMessage.addListener((message) => { 2 | if(message.action === 'maximizeVideo-ytb') { 3 | const ytpSizeButton = document.querySelector('.ytp-size-button'); 4 | if (ytpSizeButton) { 5 | document.body.classList.add('mvytp'); 6 | const ytdWatchFlexy = document.querySelector('ytd-watch-flexy'); 7 | let theater_mode = ytdWatchFlexy.hasAttribute('theater'); 8 | if (!theater_mode) { 9 | ytdWatchFlexy.setAttribute('mv', ''); 10 | ytpSizeButton.click(); 11 | } 12 | setTimeout(()=>{ 13 | window.dispatchEvent(new Event('resize')); 14 | }, 10); 15 | } 16 | } 17 | else if(message.action === 'cancelMaximaMode-ytb') { 18 | const ytpSizeButton = document.querySelector('.ytp-size-button'); 19 | if (ytpSizeButton) { 20 | document.body.classList.remove('mvytp'); 21 | const ytdWatchFlexy = document.querySelector('ytd-watch-flexy'); 22 | if (ytdWatchFlexy.hasAttribute('mv')) { 23 | ytdWatchFlexy.removeAttribute('mv'); 24 | window.dispatchEvent(new Event('resize')) 25 | setTimeout(()=>{ 26 | ytpSizeButton.click(); 27 | }, 10); 28 | } 29 | } 30 | } 31 | }) 32 | -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "__MSG_extDescription__", 3 | "manifest_version": 2, 4 | "name": "__MSG_extName__", 5 | "version": "0.0.24", 6 | "homepage_url": "https://github.com/ettoolong/MaximizeVideo", 7 | "icons": { 8 | "16": "icon/icon.svg", 9 | "32": "icon/icon.svg", 10 | "48": "icon/icon.svg", 11 | "64": "icon/icon.svg", 12 | "96": "icon/icon.svg" 13 | }, 14 | "browser_specific_settings": { 15 | "gecko": { 16 | "id": "MaximizeVideo@ettoolong", 17 | "strict_min_version": "66.0" 18 | } 19 | }, 20 | "developer": { 21 | "name": "Ett Chung", 22 | "url": "https://github.com/ettoolong/MaximizeVideo" 23 | }, 24 | "background": { 25 | "scripts": ["js/background.js"] 26 | }, 27 | 28 | "content_scripts": [ 29 | { 30 | "matches": ["http://*/*","https://*/*","file:///*"], 31 | "js": ["js/content-script.js"], 32 | "css": ["css/maximizeVideo.css"], 33 | "all_frames": true, 34 | "run_at": "document_start" 35 | }, 36 | { 37 | "matches": ["https://www.youtube.com/*"], 38 | "js": ["js/ytb.js"], 39 | "css": ["css/ytb.css"], 40 | "all_frames": false, 41 | "run_at": "document_start" 42 | } 43 | ], 44 | "browser_action": { 45 | "browser_style": true, 46 | "default_title": "__MSG_extDescription__", 47 | "default_icon": "icon/icon_b.svg" 48 | }, 49 | "permissions": [ 50 | "http://*/*", "https://*/*", "file:///*", 51 | "storage" 52 | ], 53 | "default_locale": "en", 54 | "options_ui": { 55 | "page": "options.html", 56 | "open_in_tab": false, 57 | "browser_style": true 58 | }, 59 | "commands": { 60 | "maximizeVideo": { 61 | "description": "__MSG_execute__" 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /options.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
12 | 13 | 14 |
15 |
16 |
17 | 18 |
19 |
20 |
21 | 22 | 23 |
24 |
25 | 26 | 27 |
28 |
29 |
30 |
31 | 32 |
33 |
34 | 35 |
36 |
37 |
38 | 39 | 40 |
41 |
42 | 43 | 44 |
45 |
46 |
47 | 48 | 52 | 53 |
54 |
55 | 56 | 57 | 58 | 59 | 60 |
61 |
62 | 63 |
64 |
65 | 66 | 67 | 68 | 69 |
70 |
71 | 72 |
73 |
74 | 75 | 76 |
77 |
78 | 79 |
80 |
81 | https://addons.mozilla.org/firefox/addon/popup-window/ 82 |
83 |
84 | 85 |
86 |
87 | 88 | 89 |
90 |
91 | 92 |
93 |
94 | 95 | 96 | --------------------------------------------------------------------------------