├── .gitignore ├── LICENSE ├── README.md └── src ├── COPYING ├── _metadata └── verified_contents.json ├── background.html ├── css └── cssviewer.css ├── img ├── 128-crap.png ├── 16.png ├── 22.png ├── 24.png ├── 32.png ├── 48.png ├── body.png ├── btn_large.png ├── btn_large_nb.png ├── btn_small.png ├── btn_small_nb.png ├── bullet.png ├── footer.png ├── header.png ├── list.png └── option-demo.gif ├── js ├── background.js └── cssviewer.js ├── manifest.json └── option.html /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | src.zip 3 | -------------------------------------------------------------------------------- /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 | # CSSViewer 2 | A WebExt for Firefox Quantum to extract CSS data from elements on a page. 3 | 4 | https://addons.mozilla.org/en-US/firefox/addon/cssviewer-quantum/ 5 | -------------------------------------------------------------------------------- /src/COPYING: -------------------------------------------------------------------------------- 1 | NOTE! 2 | 3 | "CSSViewer" was created by "Nicolas Huon" as a "Firefox" addon 4 | (https://addons.mozilla.org/en-US/firefox/addon/2104), but unfortunately, 5 | the original code source comes with NO SPECIFIC LICENSE or COPYRIGHT. 6 | The Firefox add-on seems abandoned since June 2008. 7 | 8 | Mohamed Mrassi attempted to contact "Nicolas" to ask for permission but to no avail. 9 | 10 | Believing that "CSSViewer" is a great resource for web developers and web designers alike, 11 | Mohamed Mrassi made a CSSViewer port to GoogleChrome on March 2010, and on February 2013 12 | he decided to release the code under the terms of the "GNU GENERAL PUBLIC LICENSE Version 2" 13 | (http://www.gnu.org/licenses/gpl-2.0.txt), so his original work would benefit 14 | the whole world and remain free. 15 | 16 | This Web-Ext for Firefox is made upon the source code provided by Mohamed Mrassi. 17 | 18 | Mohsen Khanpour, 19 | 6/2/2018 20 | 21 | ---------------------------------------- 22 | Mozilla Public License Version 2.0 23 | ================================== 24 | 25 | 1. Definitions 26 | -------------- 27 | 28 | 1.1. "Contributor" 29 | means each individual or legal entity that creates, contributes to 30 | the creation of, or owns Covered Software. 31 | 32 | 1.2. "Contributor Version" 33 | means the combination of the Contributions of others (if any) used 34 | by a Contributor and that particular Contributor's Contribution. 35 | 36 | 1.3. "Contribution" 37 | means Covered Software of a particular Contributor. 38 | 39 | 1.4. "Covered Software" 40 | means Source Code Form to which the initial Contributor has attached 41 | the notice in Exhibit A, the Executable Form of such Source Code 42 | Form, and Modifications of such Source Code Form, in each case 43 | including portions thereof. 44 | 45 | 1.5. "Incompatible With Secondary Licenses" 46 | means 47 | 48 | (a) that the initial Contributor has attached the notice described 49 | in Exhibit B to the Covered Software; or 50 | 51 | (b) that the Covered Software was made available under the terms of 52 | version 1.1 or earlier of the License, but not also under the 53 | terms of a Secondary License. 54 | 55 | 1.6. "Executable Form" 56 | means any form of the work other than Source Code Form. 57 | 58 | 1.7. "Larger Work" 59 | means a work that combines Covered Software with other material, in 60 | a separate file or files, that is not Covered Software. 61 | 62 | 1.8. "License" 63 | means this document. 64 | 65 | 1.9. "Licensable" 66 | means having the right to grant, to the maximum extent possible, 67 | whether at the time of the initial grant or subsequently, any and 68 | all of the rights conveyed by this License. 69 | 70 | 1.10. "Modifications" 71 | means any of the following: 72 | 73 | (a) any file in Source Code Form that results from an addition to, 74 | deletion from, or modification of the contents of Covered 75 | Software; or 76 | 77 | (b) any new file in Source Code Form that contains any Covered 78 | Software. 79 | 80 | 1.11. "Patent Claims" of a Contributor 81 | means any patent claim(s), including without limitation, method, 82 | process, and apparatus claims, in any patent Licensable by such 83 | Contributor that would be infringed, but for the grant of the 84 | License, by the making, using, selling, offering for sale, having 85 | made, import, or transfer of either its Contributions or its 86 | Contributor Version. 87 | 88 | 1.12. "Secondary License" 89 | means either the GNU General Public License, Version 2.0, the GNU 90 | Lesser General Public License, Version 2.1, the GNU Affero General 91 | Public License, Version 3.0, or any later versions of those 92 | licenses. 93 | 94 | 1.13. "Source Code Form" 95 | means the form of the work preferred for making modifications. 96 | 97 | 1.14. "You" (or "Your") 98 | means an individual or a legal entity exercising rights under this 99 | License. For legal entities, "You" includes any entity that 100 | controls, is controlled by, or is under common control with You. For 101 | purposes of this definition, "control" means (a) the power, direct 102 | or indirect, to cause the direction or management of such entity, 103 | whether by contract or otherwise, or (b) ownership of more than 104 | fifty percent (50%) of the outstanding shares or beneficial 105 | ownership of such entity. 106 | 107 | 2. License Grants and Conditions 108 | -------------------------------- 109 | 110 | 2.1. Grants 111 | 112 | Each Contributor hereby grants You a world-wide, royalty-free, 113 | non-exclusive license: 114 | 115 | (a) under intellectual property rights (other than patent or trademark) 116 | Licensable by such Contributor to use, reproduce, make available, 117 | modify, display, perform, distribute, and otherwise exploit its 118 | Contributions, either on an unmodified basis, with Modifications, or 119 | as part of a Larger Work; and 120 | 121 | (b) under Patent Claims of such Contributor to make, use, sell, offer 122 | for sale, have made, import, and otherwise transfer either its 123 | Contributions or its Contributor Version. 124 | 125 | 2.2. Effective Date 126 | 127 | The licenses granted in Section 2.1 with respect to any Contribution 128 | become effective for each Contribution on the date the Contributor first 129 | distributes such Contribution. 130 | 131 | 2.3. Limitations on Grant Scope 132 | 133 | The licenses granted in this Section 2 are the only rights granted under 134 | this License. No additional rights or licenses will be implied from the 135 | distribution or licensing of Covered Software under this License. 136 | Notwithstanding Section 2.1(b) above, no patent license is granted by a 137 | Contributor: 138 | 139 | (a) for any code that a Contributor has removed from Covered Software; 140 | or 141 | 142 | (b) for infringements caused by: (i) Your and any other third party's 143 | modifications of Covered Software, or (ii) the combination of its 144 | Contributions with other software (except as part of its Contributor 145 | Version); or 146 | 147 | (c) under Patent Claims infringed by Covered Software in the absence of 148 | its Contributions. 149 | 150 | This License does not grant any rights in the trademarks, service marks, 151 | or logos of any Contributor (except as may be necessary to comply with 152 | the notice requirements in Section 3.4). 153 | 154 | 2.4. Subsequent Licenses 155 | 156 | No Contributor makes additional grants as a result of Your choice to 157 | distribute the Covered Software under a subsequent version of this 158 | License (see Section 10.2) or under the terms of a Secondary License (if 159 | permitted under the terms of Section 3.3). 160 | 161 | 2.5. Representation 162 | 163 | Each Contributor represents that the Contributor believes its 164 | Contributions are its original creation(s) or it has sufficient rights 165 | to grant the rights to its Contributions conveyed by this License. 166 | 167 | 2.6. Fair Use 168 | 169 | This License is not intended to limit any rights You have under 170 | applicable copyright doctrines of fair use, fair dealing, or other 171 | equivalents. 172 | 173 | 2.7. Conditions 174 | 175 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted 176 | in Section 2.1. 177 | 178 | 3. Responsibilities 179 | ------------------- 180 | 181 | 3.1. Distribution of Source Form 182 | 183 | All distribution of Covered Software in Source Code Form, including any 184 | Modifications that You create or to which You contribute, must be under 185 | the terms of this License. You must inform recipients that the Source 186 | Code Form of the Covered Software is governed by the terms of this 187 | License, and how they can obtain a copy of this License. You may not 188 | attempt to alter or restrict the recipients' rights in the Source Code 189 | Form. 190 | 191 | 3.2. Distribution of Executable Form 192 | 193 | If You distribute Covered Software in Executable Form then: 194 | 195 | (a) such Covered Software must also be made available in Source Code 196 | Form, as described in Section 3.1, and You must inform recipients of 197 | the Executable Form how they can obtain a copy of such Source Code 198 | Form by reasonable means in a timely manner, at a charge no more 199 | than the cost of distribution to the recipient; and 200 | 201 | (b) You may distribute such Executable Form under the terms of this 202 | License, or sublicense it under different terms, provided that the 203 | license for the Executable Form does not attempt to limit or alter 204 | the recipients' rights in the Source Code Form under this License. 205 | 206 | 3.3. Distribution of a Larger Work 207 | 208 | You may create and distribute a Larger Work under terms of Your choice, 209 | provided that You also comply with the requirements of this License for 210 | the Covered Software. If the Larger Work is a combination of Covered 211 | Software with a work governed by one or more Secondary Licenses, and the 212 | Covered Software is not Incompatible With Secondary Licenses, this 213 | License permits You to additionally distribute such Covered Software 214 | under the terms of such Secondary License(s), so that the recipient of 215 | the Larger Work may, at their option, further distribute the Covered 216 | Software under the terms of either this License or such Secondary 217 | License(s). 218 | 219 | 3.4. Notices 220 | 221 | You may not remove or alter the substance of any license notices 222 | (including copyright notices, patent notices, disclaimers of warranty, 223 | or limitations of liability) contained within the Source Code Form of 224 | the Covered Software, except that You may alter any license notices to 225 | the extent required to remedy known factual inaccuracies. 226 | 227 | 3.5. Application of Additional Terms 228 | 229 | You may choose to offer, and to charge a fee for, warranty, support, 230 | indemnity or liability obligations to one or more recipients of Covered 231 | Software. However, You may do so only on Your own behalf, and not on 232 | behalf of any Contributor. You must make it absolutely clear that any 233 | such warranty, support, indemnity, or liability obligation is offered by 234 | You alone, and You hereby agree to indemnify every Contributor for any 235 | liability incurred by such Contributor as a result of warranty, support, 236 | indemnity or liability terms You offer. You may include additional 237 | disclaimers of warranty and limitations of liability specific to any 238 | jurisdiction. 239 | 240 | 4. Inability to Comply Due to Statute or Regulation 241 | --------------------------------------------------- 242 | 243 | If it is impossible for You to comply with any of the terms of this 244 | License with respect to some or all of the Covered Software due to 245 | statute, judicial order, or regulation then You must: (a) comply with 246 | the terms of this License to the maximum extent possible; and (b) 247 | describe the limitations and the code they affect. Such description must 248 | be placed in a text file included with all distributions of the Covered 249 | Software under this License. Except to the extent prohibited by statute 250 | or regulation, such description must be sufficiently detailed for a 251 | recipient of ordinary skill to be able to understand it. 252 | 253 | 5. Termination 254 | -------------- 255 | 256 | 5.1. The rights granted under this License will terminate automatically 257 | if You fail to comply with any of its terms. However, if You become 258 | compliant, then the rights granted under this License from a particular 259 | Contributor are reinstated (a) provisionally, unless and until such 260 | Contributor explicitly and finally terminates Your grants, and (b) on an 261 | ongoing basis, if such Contributor fails to notify You of the 262 | non-compliance by some reasonable means prior to 60 days after You have 263 | come back into compliance. Moreover, Your grants from a particular 264 | Contributor are reinstated on an ongoing basis if such Contributor 265 | notifies You of the non-compliance by some reasonable means, this is the 266 | first time You have received notice of non-compliance with this License 267 | from such Contributor, and You become compliant prior to 30 days after 268 | Your receipt of the notice. 269 | 270 | 5.2. If You initiate litigation against any entity by asserting a patent 271 | infringement claim (excluding declaratory judgment actions, 272 | counter-claims, and cross-claims) alleging that a Contributor Version 273 | directly or indirectly infringes any patent, then the rights granted to 274 | You by any and all Contributors for the Covered Software under Section 275 | 2.1 of this License shall terminate. 276 | 277 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all 278 | end user license agreements (excluding distributors and resellers) which 279 | have been validly granted by You or Your distributors under this License 280 | prior to termination shall survive termination. 281 | 282 | ************************************************************************ 283 | * * 284 | * 6. Disclaimer of Warranty * 285 | * ------------------------- * 286 | * * 287 | * Covered Software is provided under this License on an "as is" * 288 | * basis, without warranty of any kind, either expressed, implied, or * 289 | * statutory, including, without limitation, warranties that the * 290 | * Covered Software is free of defects, merchantable, fit for a * 291 | * particular purpose or non-infringing. The entire risk as to the * 292 | * quality and performance of the Covered Software is with You. * 293 | * Should any Covered Software prove defective in any respect, You * 294 | * (not any Contributor) assume the cost of any necessary servicing, * 295 | * repair, or correction. This disclaimer of warranty constitutes an * 296 | * essential part of this License. No use of any Covered Software is * 297 | * authorized under this License except under this disclaimer. * 298 | * * 299 | ************************************************************************ 300 | 301 | ************************************************************************ 302 | * * 303 | * 7. Limitation of Liability * 304 | * -------------------------- * 305 | * * 306 | * Under no circumstances and under no legal theory, whether tort * 307 | * (including negligence), contract, or otherwise, shall any * 308 | * Contributor, or anyone who distributes Covered Software as * 309 | * permitted above, be liable to You for any direct, indirect, * 310 | * special, incidental, or consequential damages of any character * 311 | * including, without limitation, damages for lost profits, loss of * 312 | * goodwill, work stoppage, computer failure or malfunction, or any * 313 | * and all other commercial damages or losses, even if such party * 314 | * shall have been informed of the possibility of such damages. This * 315 | * limitation of liability shall not apply to liability for death or * 316 | * personal injury resulting from such party's negligence to the * 317 | * extent applicable law prohibits such limitation. Some * 318 | * jurisdictions do not allow the exclusion or limitation of * 319 | * incidental or consequential damages, so this exclusion and * 320 | * limitation may not apply to You. * 321 | * * 322 | ************************************************************************ 323 | 324 | 8. Litigation 325 | ------------- 326 | 327 | Any litigation relating to this License may be brought only in the 328 | courts of a jurisdiction where the defendant maintains its principal 329 | place of business and such litigation shall be governed by laws of that 330 | jurisdiction, without reference to its conflict-of-law provisions. 331 | Nothing in this Section shall prevent a party's ability to bring 332 | cross-claims or counter-claims. 333 | 334 | 9. Miscellaneous 335 | ---------------- 336 | 337 | This License represents the complete agreement concerning the subject 338 | matter hereof. If any provision of this License is held to be 339 | unenforceable, such provision shall be reformed only to the extent 340 | necessary to make it enforceable. Any law or regulation which provides 341 | that the language of a contract shall be construed against the drafter 342 | shall not be used to construe this License against a Contributor. 343 | 344 | 10. Versions of the License 345 | --------------------------- 346 | 347 | 10.1. New Versions 348 | 349 | Mozilla Foundation is the license steward. Except as provided in Section 350 | 10.3, no one other than the license steward has the right to modify or 351 | publish new versions of this License. Each version will be given a 352 | distinguishing version number. 353 | 354 | 10.2. Effect of New Versions 355 | 356 | You may distribute the Covered Software under the terms of the version 357 | of the License under which You originally received the Covered Software, 358 | or under the terms of any subsequent version published by the license 359 | steward. 360 | 361 | 10.3. Modified Versions 362 | 363 | If you create software not governed by this License, and you want to 364 | create a new license for such software, you may create and use a 365 | modified version of this License if you rename the license and remove 366 | any references to the name of the license steward (except to note that 367 | such modified license differs from this License). 368 | 369 | 10.4. Distributing Source Code Form that is Incompatible With Secondary 370 | Licenses 371 | 372 | If You choose to distribute Source Code Form that is Incompatible With 373 | Secondary Licenses under the terms of this version of the License, the 374 | notice described in Exhibit B of this License must be attached. 375 | 376 | Exhibit A - Source Code Form License Notice 377 | ------------------------------------------- 378 | 379 | This Source Code Form is subject to the terms of the Mozilla Public 380 | License, v. 2.0. If a copy of the MPL was not distributed with this 381 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 382 | 383 | If it is not possible or desirable to put the notice in a particular 384 | file, then You may include the notice in a location (such as a LICENSE 385 | file in a relevant directory) where a recipient would be likely to look 386 | for such a notice. 387 | 388 | You may add additional accurate notices of copyright ownership. 389 | 390 | Exhibit B - "Incompatible With Secondary Licenses" Notice 391 | --------------------------------------------------------- 392 | 393 | This Source Code Form is "Incompatible With Secondary Licenses", as 394 | defined by the Mozilla Public License, v. 2.0. -------------------------------------------------------------------------------- /src/_metadata/verified_contents.json: -------------------------------------------------------------------------------- 1 | [{"description":"treehash per file","signed_content":{"payload":"eyJjb250ZW50X2hhc2hlcyI6W3siYmxvY2tfc2l6ZSI6NDA5NiwiZGlnZXN0Ijoic2hhMjU2IiwiZmlsZXMiOlt7InBhdGgiOiJDT1BZSU5HIiwicm9vdF9oYXNoIjoiWEpTU3lTY2FjUFBiNG02dk5SMnB4d012c09mVU9WYUJBdjAzWUtGR19ZZyJ9LHsicGF0aCI6IlJFQURNRS5tZCIsInJvb3RfaGFzaCI6IlhDNm44eDBnTEhqbGp5eENLaFFLSi02azlOaUpqWUwxSks2UXVic0VHTXcifSx7InBhdGgiOiJiYWNrZ3JvdW5kLmh0bWwiLCJyb290X2hhc2giOiI5bDkyU3pBUGlFWnByWHgzNk5zU2RnVzRzdDZGaFpHbURTX0dqdk1vNWFJIn0seyJwYXRoIjoiY3NzL2Nzc3ZpZXdlci5jc3MiLCJyb290X2hhc2giOiJlQ20xUzdLcHB0NTRvU2lQY0d2Y2lqem5EZmZMejVLOTdGMWFYU2UyUTQ0In0seyJwYXRoIjoiaW1nLzEyOC1jcmFwLnBuZyIsInJvb3RfaGFzaCI6Im9CV05WcElBTmZjN3VoTFJVeEdGNk1GS1AxRDBFZmZPdGd5Y1FUVlhWTXcifSx7InBhdGgiOiJpbWcvMTYucG5nIiwicm9vdF9oYXNoIjoid05EaWZMUGc0WFFYYkxmS3pBaF9Ha1hkZFVMdmRsdUxtOVcwb2hlMTkwQSJ9LHsicGF0aCI6ImltZy8yMi5wbmciLCJyb290X2hhc2giOiJRMFNoNEJOT0hXbTVvNnE4TF9SOUNrU2dYcE5ZVVg0WUM1UXBJR1M4blFVIn0seyJwYXRoIjoiaW1nLzI0LnBuZyIsInJvb3RfaGFzaCI6IjVncDZmdGphR0ZuR3dGVHI2Yk4wSTQzRmZoQ1FvZDRBWTZGTWpRdTR5LTQifSx7InBhdGgiOiJpbWcvMzIucG5nIiwicm9vdF9oYXNoIjoiSWQ1dmVRdWRrQVlPRHMtekRBNEc4OE5jTER4cTBTaENsaERPbGVTa0FRUSJ9LHsicGF0aCI6ImltZy80OC5wbmciLCJyb290X2hhc2giOiJDTXptXy1TY01pdzE1bWdBRzRuM3FCNEh3U2poODBEaFFYNGNiSnhNT2U4In0seyJwYXRoIjoiaW1nL2JvZHkucG5nIiwicm9vdF9oYXNoIjoiQmNjcXU1TUZoVmtOdlpCQ3hhTHVnMTdPbWdWMTFpLUhNVHZsUUN2dTZDZyJ9LHsicGF0aCI6ImltZy9idG5fbGFyZ2UucG5nIiwicm9vdF9oYXNoIjoiQVhnb2tseFdvNmsxU0kyR19uUlByVjRCakpEX1Rjdlkyc2Y4VzgzU1c4byJ9LHsicGF0aCI6ImltZy9idG5fbGFyZ2VfbmIucG5nIiwicm9vdF9oYXNoIjoiVWR3NXF4TUVyby1adlNrNXpUSjNEOU1ocWVOd0hfNUk0SVlCanVoVVVoTSJ9LHsicGF0aCI6ImltZy9idG5fc21hbGwucG5nIiwicm9vdF9oYXNoIjoiMzFBT0RTeVdENVZWNkEyWXJJaXp2V0hHZi1CSWlUdEttX1piaERvcmt2VSJ9LHsicGF0aCI6ImltZy9idG5fc21hbGxfbmIucG5nIiwicm9vdF9oYXNoIjoiX2hHeFlYOWtLZm94dzRLSDZUbmpyR3k5TUlaUGozQ01YbVdQTE1nbEJlayJ9LHsicGF0aCI6ImltZy9idWxsZXQucG5nIiwicm9vdF9oYXNoIjoiemd6OE1OUTA0R3Z2WkcwN094ZmQ3X3Z2YXRhdWdBdlR3ZG93djZIZ29PdyJ9LHsicGF0aCI6ImltZy9mb290ZXIucG5nIiwicm9vdF9oYXNoIjoiS1IzVWdLS2xWWFo1ZjVwVDhlWTQ1Z1RrOEdDX1pLdXMyY2FLSDVMamFDMCJ9LHsicGF0aCI6ImltZy9oZWFkZXIucG5nIiwicm9vdF9oYXNoIjoiUEpBaEFFNFFzcFNWX1R4d0x3Y1dDenBSQlFrT1V4TU1rSDBleTREYWlsdyJ9LHsicGF0aCI6ImltZy9saXN0LnBuZyIsInJvb3RfaGFzaCI6IjdKOUNBMWNyb0JOTkNndllTVzAxMThjMmlLejlaR1g3enE1QXpYTXRaOEkifSx7InBhdGgiOiJpbWcvb3B0aW9uLWRlbW8uZ2lmIiwicm9vdF9oYXNoIjoibXFGcFJ1bXhVZXd3TE1VazhVSnd6Z0Qzb0JaajRSZjBQN2RvNDk1VWVqdyJ9LHsicGF0aCI6ImpzL2JhY2tncm91bmQuanMiLCJyb290X2hhc2giOiJoWjF1R1NDTHprY1l5SjU4R1hzUFMwbThnNUlIZXdEb2xJTVp6ZGhnckxBIn0seyJwYXRoIjoianMvY3Nzdmlld2VyLmpzIiwicm9vdF9oYXNoIjoiNHhSUEpUQ2FEVVJVNDlrUHJEMXN2SW1OdEFITEhmU1ZteWRXdmZIMnlYSSJ9LHsiY2Fub25pY2FsX2pzb25fcm9vdF9oYXNoIjoiSzM5V3dSMnFoeTFvLTQ5ZkdUWmNRZ0ZncTMtY2ItbHliRERxYnFORXdvcyIsInBhdGgiOiJtYW5pZmVzdC5qc29uIiwicm9vdF9oYXNoIjoiQUtDb2RjaE5Bd2hfZkZhYmNhWWdDNEpIRUltQl9CTm5sVElzOFJaREljUSJ9LHsicGF0aCI6Im9wdGlvbi5odG1sIiwicm9vdF9oYXNoIjoib0E1TFdkU3Nxcm1PUXk3TnRhdG4xX1hBdnY3WTQ3Y2F6TlM2VzE4WGluYyJ9XSwiZm9ybWF0IjoidHJlZWhhc2giLCJoYXNoX2Jsb2NrX3NpemUiOjQwOTZ9XSwiaXRlbV9pZCI6ImdnZmdpamJwaWhlZWdlZmxpY2llbW9mb2JobW9mZ2NlIiwiaXRlbV92ZXJzaW9uIjoiMS43IiwicHJvdG9jb2xfdmVyc2lvbiI6MX0","signatures":[{"header":{"kid":"publisher"},"protected":"eyJhbGciOiJSUzI1NiJ9","signature":"UTB4rAAsGmRxavbyZeGmDBJ-L8v9Jva3WWyZpMGN0YqLl5rklrgAs9karK-smkc9lEgYB-F2Lpef3akUiJRUdyO36y9b58cqzeLCX-nQpKcGz8NWDElPOeQ6PMX6fDZOrE-goPPIXtrWSKECssWwWiKAypW2BXki9aaU2J2HKqc"},{"header":{"kid":"webstore"},"protected":"eyJhbGciOiJSUzI1NiJ9","signature":"WYcxQGcY_YrGULM37CsYbQ-t_d0IDWDURDDZctmn-lE6hZKZSj2WV9hZnefm_JjguTLSoYpmgz3epLmblX-6HFRV4bWa2wowlSqg-WbSQYd8rjcNK1kvWDQRlz1SuoCgUJfS6l6tEBTnDgGZVy5j5AYVMqUVe1kWsno2pHqbPLA2GD3iqY2JGOXF7WIIPcwHoBNp7Curvf4d3fLnhgMEkNb_meV_aMcsvnQWjahFhdRwyZQGvV1z_pPWp-AFaDyG6bAqfncsei165TfxiMpy2QFKJCNR_bgmyry8iKs5BQU9eve_CDTu8NCvIFBOmMe72qJ1IzGmu3SRwQQBi2O2hg"}]}}] -------------------------------------------------------------------------------- /src/background.html: -------------------------------------------------------------------------------- 1 | 2 | 12 |
13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/css/cssviewer.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * CSSViewer, A Mozilla Firefox Web Extension for fellow web developers, web designers, and hobbyists. 3 | * https://github.com/mohsenkhanpour/CSSViewer 4 | * 5 | * 6 | * This source code is licensed under the Mozilla Public License, 7 | * Version 2.0. 8 | * Mohsen Khanpour, 2018 9 | */ 10 | 11 | /* 12 | ** Common styles. Almost everything is !important; here p 13 | */ 14 | 15 | #CSSViewer_block, 16 | #CSSViewer_center, 17 | #CSSViewer_footer, 18 | .CSSViewer_category, 19 | span.CSSViewer_property, 20 | #CSSViewer_block h1, 21 | #CSSViewer_block h2, 22 | #CSSViewer_block ul, 23 | #CSSViewer_block li, 24 | #CSSViewer_block span 25 | { 26 | font-family:"Lucida sans", helvetica, sans-serif !important; 27 | font-size:10px !important; 28 | z-index:9999 !important; 29 | padding:0 !important; 30 | margin:0 !important; 31 | text-indent:0px !important; 32 | text-align:left !important; 33 | background:transparent !important; 34 | visibility: visible !important; 35 | width:auto !important; 36 | height:auto !important; 37 | line-height: 20px; 38 | } 39 | 40 | #CSSViewer_block 41 | { 42 | display:none; 43 | min-width:332px !important; 44 | font-size:10px !important; 45 | color:#555 !important; 46 | position:absolute !important; 47 | } 48 | 49 | #CSSViewer_block h1 50 | { 51 | color:#fff !important; 52 | font-size:12px !important; 53 | text-transform:none !important; 54 | text-align:center !important; 55 | width:332px !important; 56 | display:block !important; 57 | background:url("moz-extension://__MSG_@@extension_id__/img/header.png") !important; 58 | padding:30px 0 10px 0 !important; 59 | margin:5% auto; 60 | overflow:hidden !important; 61 | line-height: 5px; 62 | } 63 | 64 | #CSSViewer_center 65 | { 66 | padding:10px 32px 0 32px !important; 67 | overflow:hidden !important; 68 | background:url("moz-extension://__MSG_@@extension_id__/img/body.png") repeat-y !important; 69 | } 70 | 71 | #CSSViewer_footer 72 | { 73 | padding-top:5px; 74 | color:#555 !important; 75 | text-align:center !important; 76 | width:332px !important; 77 | height:30px !important; 78 | display:block !important; 79 | background:url("moz-extension://__MSG_@@extension_id__/img/footer.png") !important; 80 | } 81 | 82 | .CSSViewer_category 83 | { 84 | background:url("moz-extension://__MSG_@@extension_id__/img/list.png") no-repeat top left !important; 85 | padding:0 5px !important; 86 | } 87 | 88 | #CSSViewer_block h2 89 | { 90 | padding-top:6px !important; 91 | color:#6a8e46 !important; 92 | font-size:12px !important; 93 | text-align:left !important; 94 | letter-spacing:-0.5px !important; 95 | } 96 | 97 | #CSSViewer_block ul 98 | { 99 | padding:5px 5px 10px 5px !important; 100 | list-style:none !important; 101 | width:282px !important; 102 | } 103 | 104 | #CSSViewer_block li 105 | { 106 | background:url("moz-extension://__MSG_@@extension_id__/img/bullet.png") no-repeat left center !important; 107 | padding-left:10px !important; 108 | } 109 | 110 | 111 | #CSSViewer_block span.CSSViewer_property 112 | { 113 | color:#888 !important; 114 | float:left !important; 115 | width:100px !important; 116 | display:block !important; 117 | overflow:hidden !important; 118 | } 119 | -------------------------------------------------------------------------------- /src/img/128-crap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohsenkhanpour/CSSViewer/b2545614c28b122f9ad88dc3e0913d8b8cd60207/src/img/128-crap.png -------------------------------------------------------------------------------- /src/img/16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohsenkhanpour/CSSViewer/b2545614c28b122f9ad88dc3e0913d8b8cd60207/src/img/16.png -------------------------------------------------------------------------------- /src/img/22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohsenkhanpour/CSSViewer/b2545614c28b122f9ad88dc3e0913d8b8cd60207/src/img/22.png -------------------------------------------------------------------------------- /src/img/24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohsenkhanpour/CSSViewer/b2545614c28b122f9ad88dc3e0913d8b8cd60207/src/img/24.png -------------------------------------------------------------------------------- /src/img/32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohsenkhanpour/CSSViewer/b2545614c28b122f9ad88dc3e0913d8b8cd60207/src/img/32.png -------------------------------------------------------------------------------- /src/img/48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohsenkhanpour/CSSViewer/b2545614c28b122f9ad88dc3e0913d8b8cd60207/src/img/48.png -------------------------------------------------------------------------------- /src/img/body.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohsenkhanpour/CSSViewer/b2545614c28b122f9ad88dc3e0913d8b8cd60207/src/img/body.png -------------------------------------------------------------------------------- /src/img/btn_large.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohsenkhanpour/CSSViewer/b2545614c28b122f9ad88dc3e0913d8b8cd60207/src/img/btn_large.png -------------------------------------------------------------------------------- /src/img/btn_large_nb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohsenkhanpour/CSSViewer/b2545614c28b122f9ad88dc3e0913d8b8cd60207/src/img/btn_large_nb.png -------------------------------------------------------------------------------- /src/img/btn_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohsenkhanpour/CSSViewer/b2545614c28b122f9ad88dc3e0913d8b8cd60207/src/img/btn_small.png -------------------------------------------------------------------------------- /src/img/btn_small_nb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohsenkhanpour/CSSViewer/b2545614c28b122f9ad88dc3e0913d8b8cd60207/src/img/btn_small_nb.png -------------------------------------------------------------------------------- /src/img/bullet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohsenkhanpour/CSSViewer/b2545614c28b122f9ad88dc3e0913d8b8cd60207/src/img/bullet.png -------------------------------------------------------------------------------- /src/img/footer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohsenkhanpour/CSSViewer/b2545614c28b122f9ad88dc3e0913d8b8cd60207/src/img/footer.png -------------------------------------------------------------------------------- /src/img/header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohsenkhanpour/CSSViewer/b2545614c28b122f9ad88dc3e0913d8b8cd60207/src/img/header.png -------------------------------------------------------------------------------- /src/img/list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohsenkhanpour/CSSViewer/b2545614c28b122f9ad88dc3e0913d8b8cd60207/src/img/list.png -------------------------------------------------------------------------------- /src/img/option-demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohsenkhanpour/CSSViewer/b2545614c28b122f9ad88dc3e0913d8b8cd60207/src/img/option-demo.gif -------------------------------------------------------------------------------- /src/js/background.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * CSSViewer, A Mozilla Firefox Web Extension for fellow web developers, web designers, and hobbyists. 3 | * https://github.com/mohsenkhanpour/CSSViewer 4 | * 5 | * 6 | * This source code is licensed under the Mozilla Public License, 7 | * Version 2.0. 8 | * Mohsen Khanpour, 2018 9 | */ 10 | 11 | var cssViewerLoaded = false; 12 | var cssCiewerContextMenusParent = null; 13 | 14 | // Check whether new version is installed 15 | browser.runtime.onInstalled.addListener(function(details){ 16 | if(details.reason == "install" || details.reason == "update" ){ 17 | browser.tabs.create( {url: "option.html"} ); 18 | } 19 | }); 20 | 21 | /* 22 | * Inject cssviewer.js/cssviewer.css into the current page 23 | */ 24 | browser.browserAction.onClicked.addListener(function(tab) 25 | { 26 | if( tab.url.indexOf("https://chrome.google.com") == 0 || tab.url.indexOf("chrome://") == 0 ) 27 | { 28 | alert( "CSSViewer doesn't work on Google Chrome webstore!" ); 29 | 30 | return; 31 | } 32 | 33 | if( ! cssViewerLoaded ) 34 | { 35 | cssCiewerContextMenusParent = browser.contextMenus.create( { "title" : "CSSViewer console", contexts:["all"] } ); 36 | 37 | browser.contextMenus.create( { "title": "element" , contexts:["all"] , "parentId": cssCiewerContextMenusParent, "onclick": cssCiewerDebugEl } ); 38 | browser.contextMenus.create( { "title": "element.id" , contexts:["all"] , "parentId": cssCiewerContextMenusParent, "onclick": cssCiewerDebugElId } ); 39 | browser.contextMenus.create( { "title": "element.tagName" , contexts:["all"] , "parentId": cssCiewerContextMenusParent, "onclick": cssCiewerDebugElTagName } ); 40 | browser.contextMenus.create( { "title": "element.className" , contexts:["all"] , "parentId": cssCiewerContextMenusParent, "onclick": cssCiewerDebugElClassName } ); 41 | browser.contextMenus.create( { "title": "element.style" , contexts:["all"] , "parentId": cssCiewerContextMenusParent, "onclick": cssCiewerDebugElStyle } ); 42 | browser.contextMenus.create( { "title": "element.cssText" , contexts:["all"] , "parentId": cssCiewerContextMenusParent, "onclick": cssCiewerDebugElCssText } ); 43 | browser.contextMenus.create( { "title": "element.getComputedStyle" , contexts:["all"] , "parentId": cssCiewerContextMenusParent, "onclick": cssCiewerDebugElGetComputedStyle } ); 44 | browser.contextMenus.create( { "title": "element.simpleCssDefinition", contexts:["all"] , "parentId": cssCiewerContextMenusParent, "onclick": cssCiewerDebugElSimpleCssDefinition } ); 45 | } 46 | 47 | browser.tabs.executeScript(tab.id, {file:'js/cssviewer.js'}); 48 | browser.tabs.insertCSS(tab.id, {file:'css/cssviewer.css'}); 49 | 50 | cssViewerLoaded = true; 51 | }); 52 | 53 | function cssCiewerDebugEl( info, tab ) 54 | { 55 | browser.tabs.executeScript(tab.id, {code:'cssViewerCopyCssToConsole("el")'}); 56 | } 57 | 58 | function cssCiewerDebugElId( info, tab ) 59 | { 60 | browser.tabs.executeScript(tab.id, {code:'cssViewerCopyCssToConsole("id")'}); 61 | } 62 | 63 | function cssCiewerDebugElTagName( info, tab ) 64 | { 65 | browser.tabs.executeScript(tab.id, {code:'cssViewerCopyCssToConsole("tagName")'}); 66 | } 67 | 68 | function cssCiewerDebugElClassName( info, tab ) 69 | { 70 | browser.tabs.executeScript(tab.id, {code:'cssViewerCopyCssToConsole("className")'}); 71 | } 72 | 73 | function cssCiewerDebugElStyle( info, tab ) 74 | { 75 | browser.tabs.executeScript(tab.id, {code:'cssViewerCopyCssToConsole("style")'}); 76 | } 77 | 78 | function cssCiewerDebugElCssText( info, tab ) 79 | { 80 | browser.tabs.executeScript(tab.id, {code:'cssViewerCopyCssToConsole("cssText")'}); 81 | } 82 | 83 | function cssCiewerDebugElGetComputedStyle( info, tab ) 84 | { 85 | browser.tabs.executeScript(tab.id, {code:'cssViewerCopyCssToConsole("getComputedStyle")'}); 86 | } 87 | 88 | function cssCiewerDebugElSimpleCssDefinition( info, tab ) 89 | { 90 | browser.tabs.executeScript(tab.id, {code:'cssViewerCopyCssToConsole("simpleCssDefinition")'}); 91 | } 92 | -------------------------------------------------------------------------------- /src/js/cssviewer.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * CSSViewer, A Mozilla Firefox Web Extension for fellow web developers, web designers, and hobbyists. 3 | * https://github.com/mohsenkhanpour/CSSViewer 4 | * 5 | * 6 | * This source code is licensed under the Mozilla Public License, 7 | * Version 2.0. 8 | * Mohsen Khanpour, 2018 9 | */ 10 | 11 | // Roadmap/ToDos 12 | // 1. Make the initial code more readable 13 | // 2. Comment the initial code 14 | // 3. Fix issues if any 15 | // 4. Add new features (feasible and useful ones) 16 | // 5. Make a new branch and start re-factoring the entire code 17 | 18 | /* 19 | ** Globals 20 | */ 21 | 22 | var CSSViewer_element 23 | 24 | var CSSViewer_element_cssDefinition 25 | 26 | var CSSViewer_container 27 | 28 | var CSSViewer_current_element 29 | 30 | // CSS Properties 31 | var CSSViewer_pFont = new Array( 32 | 'font-family', 33 | 'font-size', 34 | 'font-style', 35 | 'font-variant', 36 | 'font-weight', 37 | 'letter-spacing', 38 | 'line-height', 39 | 'text-decoration', 40 | 'text-align', 41 | 'text-indent', 42 | 'text-transform', 43 | 'vertical-align', 44 | 'white-space', 45 | 'word-spacing' 46 | ); 47 | 48 | var CSSViewer_pColorBg = new Array( 49 | 'background-attachment', 50 | 'background-color', 51 | 'background-image', 52 | 'background-position', 53 | 'background-repeat', 54 | 'color' 55 | ); 56 | 57 | var CSSViewer_pBox = new Array( 58 | 'height', 59 | 'width', 60 | 'border', 61 | 'border-top', 62 | 'border-right', 63 | 'border-bottom', 64 | 'border-left', 65 | 'margin', 66 | 'padding', 67 | 'max-height', 68 | 'min-height', 69 | 'max-width', 70 | 'min-width' 71 | ); 72 | 73 | var CSSViewer_pPositioning = new Array( 74 | 'position', 75 | 'top', 76 | 'bottom', 77 | 'right', 78 | 'left', 79 | 'float', 80 | 'display', 81 | 'clear', 82 | 'z-index' 83 | ); 84 | 85 | var CSSViewer_pList = new Array( 86 | 'list-style-image', 87 | 'list-style-type', 88 | 'list-style-position' 89 | ); 90 | 91 | var CSSViewer_pTable = new Array( 92 | 'border-collapse', 93 | 'border-spacing', 94 | 'caption-side', 95 | 'empty-cells', 96 | 'table-layout' 97 | ); 98 | 99 | var CSSViewer_pMisc = new Array( 100 | 'overflow', 101 | 'cursor', 102 | 'visibility' 103 | ); 104 | 105 | var CSSViewer_pEffect = new Array( 106 | 'transform', 107 | 'transition', 108 | 'outline', 109 | 'outline-offset', 110 | 'box-sizing', 111 | 'resize', 112 | 'text-shadow', 113 | 'text-overflow', 114 | 'word-wrap', 115 | 'box-shadow', 116 | 'border-top-left-radius', 117 | 'border-top-right-radius', 118 | 'border-bottom-left-radius', 119 | 'border-bottom-right-radius' 120 | ); 121 | 122 | // CSS Property categories 123 | var CSSViewer_categories = { 124 | 'pFontText' : CSSViewer_pFont, 125 | 'pColorBg' : CSSViewer_pColorBg, 126 | 'pBox' : CSSViewer_pBox, 127 | 'pPositioning' : CSSViewer_pPositioning, 128 | 'pList' : CSSViewer_pList, 129 | 'pTable' : CSSViewer_pTable, 130 | 'pMisc' : CSSViewer_pMisc, 131 | 'pEffect' : CSSViewer_pEffect 132 | }; 133 | 134 | var CSSViewer_categoriesTitle = { 135 | 'pFontText' : 'Font & Text', 136 | 'pColorBg' : 'Color & Background', 137 | 'pBox' : 'Box', 138 | 'pPositioning' : 'Positioning', 139 | 'pList' : 'List', 140 | 'pTable' : 'Table', 141 | 'pMisc' : 'Miscellaneous', 142 | 'pEffect' : 'Effects' 143 | }; 144 | 145 | // Table tagnames 146 | var CSSViewer_tableTagNames = new Array( 147 | 'TABLE', 148 | 'CAPTION', 149 | 'THEAD', 150 | 'TBODY', 151 | 'TFOOT', 152 | 'COLGROUP', 153 | 'COL', 154 | 'TR', 155 | 'TH', 156 | 'TD' 157 | ); 158 | 159 | var CSSViewer_listTagNames = new Array( 160 | 'UL', 161 | 'LI', 162 | 'DD', 163 | 'DT', 164 | 'OL' 165 | ); 166 | 167 | // Hexadecimal 168 | var CSSViewer_hexa = new Array( 169 | '0', 170 | '1', 171 | '2', 172 | '3', 173 | '4', 174 | '5', 175 | '6', 176 | '7', 177 | '8', 178 | '9', 179 | 'A', 180 | 'B', 181 | 'C', 182 | 'D', 183 | 'E', 184 | 'F' 185 | ); 186 | 187 | /* 188 | ** Utils 189 | */ 190 | 191 | function GetCurrentDocument() 192 | { 193 | return window.document; 194 | } 195 | 196 | function IsInArray(array, name) 197 | { 198 | for (var i = 0; i < array.length; i++) { 199 | if (name == array[i]) 200 | return true; 201 | } 202 | 203 | return false; 204 | } 205 | 206 | function DecToHex(nb) 207 | { 208 | var nbHexa = ''; 209 | 210 | nbHexa += CSSViewer_hexa[Math.floor(nb / 16)]; 211 | nb = nb % 16; 212 | nbHexa += CSSViewer_hexa[nb]; 213 | 214 | return nbHexa; 215 | } 216 | 217 | function RGBToHex(str) 218 | { 219 | var start = str.search(/\(/) + 1; 220 | var end = str.search(/\)/); 221 | 222 | str = str.slice(start, end); 223 | 224 | var hexValues = str.split(', '); 225 | var hexStr = '#'; 226 | 227 | for (var i = 0; i < hexValues.length; i++) { 228 | hexStr += DecToHex(hexValues[i]); 229 | } 230 | 231 | if( hexStr == "#00000000" ){ 232 | hexStr = "#FFFFFF"; 233 | } 234 | 235 | hexStr = ' ' + hexStr; 236 | 237 | return hexStr; 238 | } 239 | 240 | function GetFileName(str) 241 | { 242 | var start = str.search(/\(/) + 1; 243 | var end = str.search(/\)/); 244 | 245 | str = str.slice(start, end); 246 | 247 | var path = str.split('/'); 248 | 249 | return path[path.length - 1]; 250 | } 251 | 252 | function RemoveExtraFloat(nb) 253 | { 254 | nb = nb.substr(0, nb.length - 2); 255 | 256 | return Math.round(nb) + 'px'; 257 | } 258 | 259 | /* 260 | * CSSFunc 261 | */ 262 | 263 | function GetCSSProperty(element, property) 264 | { 265 | return element.getPropertyValue(property); 266 | } 267 | 268 | function SetCSSProperty(element, property) 269 | { 270 | var document = GetCurrentDocument(); 271 | var li = document.getElementById('CSSViewer_' + property); 272 | 273 | li.lastChild.innerHTML = " : " + element.getPropertyValue(property); 274 | } 275 | 276 | function SetCSSPropertyIf(element, property, condition) 277 | { 278 | var document = GetCurrentDocument(); 279 | var li = document.getElementById('CSSViewer_' + property); 280 | 281 | if (condition) { 282 | li.lastChild.innerHTML = " : " + element.getPropertyValue(property); 283 | li.style.display = 'block'; 284 | 285 | return 1; 286 | } 287 | else { 288 | li.style.display = 'none'; 289 | 290 | return 0; 291 | } 292 | } 293 | 294 | function SetCSSPropertyValue(element, property, value) 295 | { 296 | var document = GetCurrentDocument(); 297 | var li = document.getElementById('CSSViewer_' + property); 298 | 299 | li.lastChild.innerHTML = " : " + value; 300 | li.style.display = 'block'; 301 | } 302 | 303 | function SetCSSPropertyValueIf(element, property, value, condition) 304 | { 305 | var document = GetCurrentDocument(); 306 | var li = document.getElementById('CSSViewer_' + property); 307 | 308 | if (condition) { 309 | li.lastChild.innerHTML = " : " + value; 310 | li.style.display = 'block'; 311 | 312 | return 1; 313 | } 314 | else { 315 | li.style.display = 'none'; 316 | 317 | return 0; 318 | } 319 | } 320 | 321 | function HideCSSProperty(property) 322 | { 323 | var document = GetCurrentDocument(); 324 | var li = document.getElementById('CSSViewer_' + property); 325 | 326 | li.style.display = 'none'; 327 | } 328 | 329 | function HideCSSCategory(category) 330 | { 331 | var document = GetCurrentDocument(); 332 | var div = document.getElementById('CSSViewer_' + category); 333 | 334 | div.style.display = 'none'; 335 | } 336 | 337 | function ShowCSSCategory(category) 338 | { 339 | var document = GetCurrentDocument(); 340 | var div = document.getElementById('CSSViewer_' + category); 341 | 342 | div.style.display = 'block'; 343 | } 344 | 345 | function UpdatefontText(element) 346 | { 347 | // Font 348 | SetCSSProperty(element, 'font-family'); 349 | SetCSSProperty(element, 'font-size'); 350 | 351 | SetCSSPropertyIf(element, 'font-weight' , GetCSSProperty(element, 'font-weight') != '400'); 352 | SetCSSPropertyIf(element, 'font-variant' , GetCSSProperty(element, 'font-variant') != 'normal'); 353 | SetCSSPropertyIf(element, 'font-style' , GetCSSProperty(element, 'font-style') != 'normal'); 354 | 355 | // Text 356 | SetCSSPropertyIf(element, 'letter-spacing' , GetCSSProperty(element, 'letter-spacing') != 'normal'); 357 | SetCSSPropertyIf(element, 'line-height' , GetCSSProperty(element, 'line-height') != 'normal'); 358 | SetCSSPropertyIf(element, 'text-decoration', GetCSSProperty(element, 'text-decoration') != 'none'); 359 | SetCSSPropertyIf(element, 'text-align' , GetCSSProperty(element, 'text-align') != 'start'); 360 | SetCSSPropertyIf(element, 'text-indent' , GetCSSProperty(element, 'text-indent') != '0px'); 361 | SetCSSPropertyIf(element, 'text-transform' , GetCSSProperty(element, 'text-transform') != 'none'); 362 | SetCSSPropertyIf(element, 'vertical-align' , GetCSSProperty(element, 'vertical-align') != 'baseline'); 363 | SetCSSPropertyIf(element, 'white-space' , GetCSSProperty(element, 'white-space') != 'normal'); 364 | SetCSSPropertyIf(element, 'word-spacing' , GetCSSProperty(element, 'word-spacing') != 'normal'); 365 | } 366 | 367 | function UpdateColorBg(element) 368 | { 369 | // Color 370 | SetCSSPropertyValue(element, 'color', RGBToHex(GetCSSProperty(element, 'color'))); 371 | 372 | // Background 373 | SetCSSPropertyValueIf(element, 'background-color', RGBToHex(GetCSSProperty(element, 'background-color')), GetCSSProperty(element, 'background-color') != 'transparent'); 374 | SetCSSPropertyIf(element, 'background-attachment', GetCSSProperty(element, 'background-attachment') != 'scroll'); 375 | SetCSSPropertyValueIf(element, 'background-image', GetFileName(GetCSSProperty(element, 'background-image')), GetCSSProperty(element, 'background-image') != 'none'); 376 | SetCSSPropertyIf(element, 'background-position' , GetCSSProperty(element, 'background-position') != ''); 377 | SetCSSPropertyIf(element, 'background-repeat' , GetCSSProperty(element, 'background-repeat') != 'repeat'); 378 | } 379 | 380 | function UpdateBox(element) 381 | { 382 | // Width/Height 383 | SetCSSPropertyIf(element, 'height', RemoveExtraFloat(GetCSSProperty(element, 'height')) != 'auto'); 384 | SetCSSPropertyIf(element, 'width', RemoveExtraFloat(GetCSSProperty(element, 'width')) != 'auto'); 385 | 386 | // Border 387 | var borderTop = RemoveExtraFloat(GetCSSProperty(element, 'border-top-width')) + ' ' + GetCSSProperty(element, 'border-top-style') + ' ' + RGBToHex(GetCSSProperty(element, 'border-top-color')); 388 | var borderBottom = RemoveExtraFloat(GetCSSProperty(element, 'border-bottom-width')) + ' ' + GetCSSProperty(element, 'border-bottom-style') + ' ' + RGBToHex(GetCSSProperty(element, 'border-bottom-color')); 389 | var borderRight = RemoveExtraFloat(GetCSSProperty(element, 'border-right-width')) + ' ' + GetCSSProperty(element, 'border-right-style') + ' ' + RGBToHex(GetCSSProperty(element, 'border-right-color')); 390 | var borderLeft = RemoveExtraFloat(GetCSSProperty(element, 'border-left-width')) + ' ' + GetCSSProperty(element, 'border-left-style') + ' ' + RGBToHex(GetCSSProperty(element, 'border-left-color')); 391 | 392 | if (borderTop == borderBottom && borderBottom == borderRight && borderRight == borderLeft && GetCSSProperty(element, 'border-top-style') != 'none') { 393 | SetCSSPropertyValue(element, 'border', borderTop); 394 | 395 | HideCSSProperty('border-top'); 396 | HideCSSProperty('border-bottom'); 397 | HideCSSProperty('border-right'); 398 | HideCSSProperty('border-left'); 399 | } 400 | else { 401 | SetCSSPropertyValueIf(element, 'border-top' , borderTop , GetCSSProperty(element, 'border-top-style') != 'none'); 402 | SetCSSPropertyValueIf(element, 'border-bottom', borderBottom, GetCSSProperty(element, 'border-bottom-style') != 'none'); 403 | SetCSSPropertyValueIf(element, 'border-right' , borderRight , GetCSSProperty(element, 'border-right-style') != 'none'); 404 | SetCSSPropertyValueIf(element, 'border-left' , borderLeft , GetCSSProperty(element, 'border-left-style') != 'none'); 405 | 406 | HideCSSProperty('border'); 407 | } 408 | 409 | // Margin 410 | var marginTop = RemoveExtraFloat(GetCSSProperty(element, 'margin-top')); 411 | var marginBottom = RemoveExtraFloat(GetCSSProperty(element, 'margin-bottom')); 412 | var marginRight = RemoveExtraFloat(GetCSSProperty(element, 'margin-right')); 413 | var marginLeft = RemoveExtraFloat(GetCSSProperty(element, 'margin-left')); 414 | var margin = (marginTop == '0px' ? '0' : marginTop) + ' ' + (marginRight == '0px' ? '0' : marginRight) + ' ' + (marginBottom == '0px' ? '0' : marginBottom) + ' ' + (marginLeft == '0px' ? '0' : marginLeft); 415 | 416 | SetCSSPropertyValueIf(element, 'margin', margin, margin != '0 0 0 0'); 417 | 418 | // padding 419 | var paddingTop = RemoveExtraFloat(GetCSSProperty(element, 'padding-top')); 420 | var paddingBottom = RemoveExtraFloat(GetCSSProperty(element, 'padding-bottom')); 421 | var paddingRight = RemoveExtraFloat(GetCSSProperty(element, 'padding-right')); 422 | var paddingLeft = RemoveExtraFloat(GetCSSProperty(element, 'padding-left')); 423 | var padding = (paddingTop == '0px' ? '0' : paddingTop) + ' ' + (paddingRight == '0px' ? '0' : paddingRight) + ' ' + (paddingBottom == '0px' ? '0' : paddingBottom) + ' ' + (paddingLeft == '0px' ? '0' : paddingLeft); 424 | 425 | SetCSSPropertyValueIf(element, 'padding', padding, padding != '0 0 0 0'); 426 | 427 | // Max/Min Width/Height 428 | SetCSSPropertyIf(element, 'min-height', GetCSSProperty(element, 'min-height') != '0px'); 429 | SetCSSPropertyIf(element, 'max-height', GetCSSProperty(element, 'max-height') != 'none'); 430 | SetCSSPropertyIf(element, 'min-width' , GetCSSProperty(element, 'min-width') != '0px'); 431 | SetCSSPropertyIf(element, 'max-width' , GetCSSProperty(element, 'max-width') != 'none'); 432 | } 433 | 434 | function UpdatePositioning(element) 435 | { 436 | SetCSSPropertyIf(element, 'position', GetCSSProperty(element, 'position') != 'static'); 437 | SetCSSPropertyIf(element, 'top' , GetCSSProperty(element, 'top') != 'auto'); 438 | SetCSSPropertyIf(element, 'bottom' , GetCSSProperty(element, 'bottom') != 'auto'); 439 | SetCSSPropertyIf(element, 'right' , GetCSSProperty(element, 'right') != 'auto'); 440 | SetCSSPropertyIf(element, 'left' , GetCSSProperty(element, 'left') != 'auto'); 441 | SetCSSPropertyIf(element, 'float' , GetCSSProperty(element, 'float') != 'none'); 442 | 443 | SetCSSProperty(element, 'display'); 444 | 445 | SetCSSPropertyIf(element, 'clear' , GetCSSProperty(element, 'clear') != 'none'); 446 | SetCSSPropertyIf(element, 'z-index' , GetCSSProperty(element, 'z-index') != 'auto'); 447 | } 448 | 449 | function UpdateTable(element, tagName) 450 | { 451 | if (IsInArray(CSSViewer_tableTagNames, tagName)) { 452 | var nbProperties = 0; 453 | 454 | nbProperties += SetCSSPropertyIf(element, 'border-collapse', GetCSSProperty(element, 'border-collapse') != 'separate'); 455 | nbProperties += SetCSSPropertyIf(element, 'border-spacing' , GetCSSProperty(element, 'border-spacing') != '0px 0px'); 456 | nbProperties += SetCSSPropertyIf(element, 'caption-side' , GetCSSProperty(element, 'caption-side') != 'top'); 457 | nbProperties += SetCSSPropertyIf(element, 'empty-cells' , GetCSSProperty(element, 'empty-cells') != 'show'); 458 | nbProperties += SetCSSPropertyIf(element, 'table-layout' , GetCSSProperty(element, 'table-layout') != 'auto'); 459 | 460 | if (nbProperties > 0) 461 | ShowCSSCategory('pTable'); 462 | else 463 | HideCSSCategory('pTable'); 464 | } 465 | else { 466 | HideCSSCategory('pTable'); 467 | } 468 | } 469 | 470 | function UpdateList(element, tagName) 471 | { 472 | if (IsInArray(CSSViewer_listTagNames, tagName)) { 473 | ShowCSSCategory('pList'); 474 | 475 | var listStyleImage = GetCSSProperty(element, 'list-style-image'); 476 | 477 | if (listStyleImage == 'none') { 478 | SetCSSProperty(element, 'list-style-type'); 479 | HideCSSProperty('list-style-image'); 480 | } 481 | else { 482 | SetCSSPropertyValue(element, 'list-style-image', listStyleImage); 483 | HideCSSProperty('list-style-type'); 484 | } 485 | 486 | SetCSSProperty(element, 'list-style-position'); 487 | } 488 | else { 489 | HideCSSCategory('pList'); 490 | } 491 | } 492 | 493 | function UpdateMisc(element) 494 | { 495 | var nbProperties = 0; 496 | 497 | nbProperties += SetCSSPropertyIf(element, 'overflow' , GetCSSProperty(element, 'overflow') != 'visible'); 498 | nbProperties += SetCSSPropertyIf(element, 'cursor' , GetCSSProperty(element, 'cursor') != 'auto'); 499 | nbProperties += SetCSSPropertyIf(element, 'visibility', GetCSSProperty(element, 'visibility') != 'visible'); 500 | 501 | if (nbProperties > 0) 502 | ShowCSSCategory('pMisc'); 503 | else 504 | HideCSSCategory('pMisc'); 505 | } 506 | 507 | function UpdateEffects(element) 508 | { 509 | var nbProperties = 0; 510 | 511 | nbProperties += SetCSSPropertyIf(element, 'transform' , GetCSSProperty(element, 'transform') ); 512 | nbProperties += SetCSSPropertyIf(element, 'transition' , GetCSSProperty(element, 'transition') ); 513 | nbProperties += SetCSSPropertyIf(element, 'outline' , GetCSSProperty(element, 'outline') ); 514 | nbProperties += SetCSSPropertyIf(element, 'outline-offset' , GetCSSProperty(element, 'outline-offset') != '0px'); 515 | nbProperties += SetCSSPropertyIf(element, 'box-sizing' , GetCSSProperty(element, 'box-sizing') != 'content-box'); 516 | nbProperties += SetCSSPropertyIf(element, 'resize' , GetCSSProperty(element, 'resize') != 'none'); 517 | 518 | nbProperties += SetCSSPropertyIf(element, 'text-shadow' , GetCSSProperty(element, 'text-shadow') != 'none'); 519 | nbProperties += SetCSSPropertyIf(element, 'text-overflow' , GetCSSProperty(element, 'text-overflow') != 'clip'); 520 | nbProperties += SetCSSPropertyIf(element, 'word-wrap' , GetCSSProperty(element, 'word-wrap') != 'normal'); 521 | nbProperties += SetCSSPropertyIf(element, 'box-shadow' , GetCSSProperty(element, 'box-shadow') != 'none'); 522 | 523 | nbProperties += SetCSSPropertyIf(element, 'border-top-left-radius' , GetCSSProperty(element, 'border-top-left-radius') != '0px'); 524 | nbProperties += SetCSSPropertyIf(element, 'border-top-right-radius' , GetCSSProperty(element, 'border-top-right-radius') != '0px'); 525 | nbProperties += SetCSSPropertyIf(element, 'border-bottom-left-radius' , GetCSSProperty(element, 'border-bottom-left-radius') != '0px'); 526 | nbProperties += SetCSSPropertyIf(element, 'border-bottom-right-radius', GetCSSProperty(element, 'border-bottom-right-radius') != '0px'); 527 | 528 | if (nbProperties > 0) 529 | ShowCSSCategory('pEffect'); 530 | else 531 | HideCSSCategory('pEffect'); 532 | } 533 | 534 | /* 535 | ** Event Handlers 536 | */ 537 | 538 | function CSSViewerMouseOver(e) 539 | { 540 | // Block 541 | var document = GetCurrentDocument(); 542 | var block = document.getElementById('CSSViewer_block'); 543 | 544 | if( ! block ){ 545 | return; 546 | } 547 | 548 | block.firstChild.innerHTML = '<' + this.tagName + '>' + (this.id == '' ? '' : ' #' + this.id) + (this.className == '' ? '' : ' .' + this.className); 549 | 550 | // Outline element 551 | if (this.tagName != 'body') { 552 | this.style.outline = '1px dashed #f00'; 553 | CSSViewer_current_element = this; 554 | } 555 | 556 | // Updating CSS properties 557 | var element = document.defaultView.getComputedStyle(this, null); 558 | 559 | UpdatefontText(element); 560 | UpdateColorBg(element); 561 | UpdateBox(element); 562 | UpdatePositioning(element); 563 | UpdateTable(element, this.tagName); 564 | UpdateList(element, this.tagName); 565 | UpdateMisc(element); 566 | UpdateEffects(element); 567 | 568 | CSSViewer_element = this; 569 | 570 | cssViewerRemoveElement("cssViewerInsertMessage"); 571 | 572 | e.stopPropagation(); 573 | 574 | // generate simple css definition 575 | CSSViewer_element_cssDefinition = this.tagName.toLowerCase() + (this.id == '' ? '' : ' #' + this.id) + (this.className == '' ? '' : ' .' + this.className) + " {\n"; 576 | 577 | CSSViewer_element_cssDefinition += "\t/* Font & Text */\n"; 578 | for (var i = 0; i < CSSViewer_pFont.length; i++) 579 | CSSViewer_element_cssDefinition += "\t" + CSSViewer_pFont[i] + ': ' + element.getPropertyValue( CSSViewer_pFont[i] ) + ";\n"; 580 | 581 | CSSViewer_element_cssDefinition += "\n\t/* Color & Background */\n"; 582 | for (var i = 0; i < CSSViewer_pColorBg.length; i++) 583 | CSSViewer_element_cssDefinition += "\t" + CSSViewer_pColorBg[i] + ': ' + element.getPropertyValue( CSSViewer_pColorBg[i] ) + ";\n"; 584 | 585 | CSSViewer_element_cssDefinition += "\n\t/* Box */\n"; 586 | for (var i = 0; i < CSSViewer_pBox.length; i++) 587 | CSSViewer_element_cssDefinition += "\t" + CSSViewer_pBox[i] + ': ' + element.getPropertyValue( CSSViewer_pBox[i] ) + ";\n"; 588 | 589 | CSSViewer_element_cssDefinition += "\n\t/* Positioning */\n"; 590 | for (var i = 0; i < CSSViewer_pPositioning.length; i++) 591 | CSSViewer_element_cssDefinition += "\t" + CSSViewer_pPositioning[i] + ': ' + element.getPropertyValue( CSSViewer_pPositioning[i] ) + ";\n"; 592 | 593 | CSSViewer_element_cssDefinition += "\n\t/* List */\n"; 594 | for (var i = 0; i < CSSViewer_pList.length; i++) 595 | CSSViewer_element_cssDefinition += "\t" + CSSViewer_pList[i] + ': ' + element.getPropertyValue( CSSViewer_pList[i] ) + ";\n"; 596 | 597 | CSSViewer_element_cssDefinition += "\n\t/* Table */\n"; 598 | for (var i = 0; i < CSSViewer_pTable.length; i++) 599 | CSSViewer_element_cssDefinition += "\t" + CSSViewer_pTable[i] + ': ' + element.getPropertyValue( CSSViewer_pTable[i] ) + ";\n"; 600 | 601 | CSSViewer_element_cssDefinition += "\n\t/* Miscellaneous */\n"; 602 | for (var i = 0; i < CSSViewer_pMisc.length; i++) 603 | CSSViewer_element_cssDefinition += "\t" + CSSViewer_pMisc[i] + ': ' + element.getPropertyValue( CSSViewer_pMisc[i] ) + ";\n"; 604 | 605 | CSSViewer_element_cssDefinition += "\n\t/* Effects */\n"; 606 | for (var i = 0; i < CSSViewer_pEffect.length; i++) 607 | CSSViewer_element_cssDefinition += "\t" + CSSViewer_pEffect[i] + ': ' + element.getPropertyValue( CSSViewer_pEffect[i] ) + ";\n"; 608 | 609 | CSSViewer_element_cssDefinition += "}"; 610 | 611 | // console.log( element.cssText ); //< debug the hovered el css 612 | } 613 | 614 | function CSSViewerMouseOut(e) 615 | { 616 | this.style.outline = ''; 617 | 618 | e.stopPropagation(); 619 | } 620 | 621 | function CSSViewerMouseMove(e) 622 | { 623 | var document = GetCurrentDocument(); 624 | var block = document.getElementById('CSSViewer_block'); 625 | 626 | if( ! block ){ 627 | return; 628 | } 629 | 630 | block.style.display = 'block'; 631 | 632 | var pageWidth = window.innerWidth; 633 | var pageHeight = window.innerHeight; 634 | var blockWidth = 332; 635 | var blockHeight = document.defaultView.getComputedStyle(block, null).getPropertyValue('height'); 636 | 637 | blockHeight = blockHeight.substr(0, blockHeight.length - 2) * 1; 638 | 639 | if ((e.pageX + blockWidth) > pageWidth) { 640 | if ((e.pageX - blockWidth - 10) > 0) 641 | block.style.left = e.pageX - blockWidth - 40 + 'px'; 642 | else 643 | block.style.left = 0 + 'px'; 644 | } 645 | else 646 | block.style.left = (e.pageX + 20) + 'px'; 647 | 648 | if ((e.pageY + blockHeight) > pageHeight) { 649 | if ((e.pageY - blockHeight - 10) > 0) 650 | block.style.top = e.pageY - blockHeight - 20 + 'px'; 651 | else 652 | block.style.top = 0 + 'px'; 653 | } 654 | else 655 | block.style.top = (e.pageY + 20) + 'px'; 656 | 657 | // adapt block top to screen offset 658 | inView = CSSViewerIsElementInViewport(block); 659 | 660 | if( ! inView ) 661 | block.style.top = ( window.pageYOffset + 20 ) + 'px'; 662 | 663 | e.stopPropagation(); 664 | } 665 | 666 | // http://stackoverflow.com/a/7557433 667 | function CSSViewerIsElementInViewport(el) { 668 | var rect = el.getBoundingClientRect(); 669 | 670 | return ( 671 | rect.top >= 0 && 672 | rect.left >= 0 && 673 | rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && 674 | rect.right <= (window.innerWidth || document.documentElement.clientWidth) 675 | ); 676 | } 677 | 678 | /* 679 | * CSSViewer Class 680 | */ 681 | function CSSViewer() 682 | { 683 | // Create a block to display informations 684 | this.CreateBlock = function() { 685 | var document = GetCurrentDocument(); 686 | var block; 687 | 688 | if (document) { 689 | // Create a div block 690 | block = document.createElement('div'); 691 | block.id = 'CSSViewer_block'; 692 | 693 | // Insert a title for CSS selector 694 | var header = document.createElement('h1'); 695 | 696 | header.appendChild(document.createTextNode('')); 697 | block.appendChild(header); 698 | 699 | // Insert all properties 700 | var center = document.createElement('div'); 701 | 702 | center.id = 'CSSViewer_center'; 703 | 704 | for (var cat in CSSViewer_categories) { 705 | var div = document.createElement('div'); 706 | 707 | div.id = 'CSSViewer_' + cat; 708 | div.className = 'CSSViewer_category'; 709 | 710 | var h2 = document.createElement('h2'); 711 | 712 | h2.appendChild(document.createTextNode(CSSViewer_categoriesTitle[cat])); 713 | 714 | var ul = document.createElement('ul'); 715 | var properties = CSSViewer_categories[cat]; 716 | 717 | for (var i = 0; i < properties.length; i++) { 718 | var li = document.createElement('li'); 719 | 720 | li.id = 'CSSViewer_' + properties[i]; 721 | 722 | var spanName = document.createElement('span'); 723 | 724 | spanName.className = 'CSSViewer_property'; 725 | 726 | var spanValue = document.createElement('span'); 727 | 728 | spanName.appendChild(document.createTextNode(properties[i])); 729 | li.appendChild(spanName); 730 | li.appendChild(spanValue); 731 | ul.appendChild(li); 732 | } 733 | 734 | div.appendChild(h2); 735 | div.appendChild(ul); 736 | center.appendChild(div); 737 | } 738 | 739 | block.appendChild(center); 740 | 741 | // Insert a footer 742 | var footer = document.createElement('div'); 743 | 744 | footer.id = 'CSSViewer_footer'; 745 | 746 | //< 747 | footer.appendChild( document.createTextNode('CSSViewer 1.1. Keys: [F] Un/Freeze. [C] CSS. [ESC] Close.') ); 748 | block.appendChild(footer); 749 | } 750 | 751 | cssViewerInsertMessage( "CSSViewer loaded! Hover any element you want to inspect in the page." ); 752 | 753 | return block; 754 | } 755 | 756 | // Get all elements within the given element 757 | this.GetAllElements = function(element) 758 | { 759 | var elements = new Array(); 760 | 761 | if (element && element.hasChildNodes()) { 762 | elements.push(element); 763 | 764 | var childs = element.childNodes; 765 | 766 | for (var i = 0; i < childs.length; i++) { 767 | if (childs[i].hasChildNodes()) { 768 | elements = elements.concat(this.GetAllElements(childs[i])); 769 | } 770 | else if (childs[i].nodeType == 1) { 771 | elements.push(childs[i]); 772 | } 773 | } 774 | } 775 | 776 | return elements; 777 | } 778 | 779 | // Add bool for knowing all elements having event listeners or not 780 | this.haveEventListeners = false; 781 | 782 | // Add event listeners for all elements in the current document 783 | this.AddEventListeners = function() 784 | { 785 | var document = GetCurrentDocument(); 786 | var elements = this.GetAllElements(document.body); 787 | 788 | for (var i = 0; i < elements.length; i++) { 789 | elements[i].addEventListener("mouseover", CSSViewerMouseOver, false); 790 | elements[i].addEventListener("mouseout", CSSViewerMouseOut, false); 791 | elements[i].addEventListener("mousemove", CSSViewerMouseMove, false); 792 | } 793 | this.haveEventListeners = true; 794 | } 795 | 796 | // Remove event listeners for all elements in the current document 797 | this.RemoveEventListeners = function() 798 | { 799 | var document = GetCurrentDocument(); 800 | var elements = this.GetAllElements(document.body); 801 | 802 | for (var i = 0; i < elements.length; i++){ 803 | elements[i].removeEventListener("mouseover", CSSViewerMouseOver, false); 804 | elements[i].removeEventListener("mouseout", CSSViewerMouseOut, false); 805 | elements[i].removeEventListener("mousemove", CSSViewerMouseMove, false); 806 | } 807 | this.haveEventListeners = false; 808 | } 809 | 810 | // Set the title of the block 811 | this.SetTitle = function() 812 | {} 813 | 814 | // Add a stylesheet to the current document 815 | this.AddCSS = function(cssFile) 816 | { 817 | var document = GetCurrentDocument(); 818 | var link = document.createElement("link"); 819 | 820 | link.setAttribute("href", cssFile); 821 | link.setAttribute("rel", "stylesheet"); 822 | link.setAttribute("type", "text/css"); 823 | 824 | var heads = document.getElementsByTagName("head"); 825 | 826 | if(heads.length > 0) 827 | heads[0].appendChild(link); 828 | else 829 | document.documentElement.appendChild(link); 830 | } 831 | 832 | this.RemoveCSS = function(cssFile) 833 | { 834 | var document = GetCurrentDocument(); 835 | var links = document.getElementsByTagName('link'); 836 | 837 | for (var i = 0; i < links.length; i++) { 838 | if (links[i].rel == "stylesheet" && links[i].href == cssFile) { 839 | var heads = document.getElementsByTagName("head"); 840 | 841 | if(heads.length > 0) { 842 | heads[0].removeChild(links[i]); 843 | } 844 | 845 | return; 846 | } 847 | } 848 | } 849 | } 850 | 851 | /* 852 | * Check if CSSViewer is enabled 853 | */ 854 | CSSViewer.prototype.IsEnabled = function() 855 | { 856 | var document = GetCurrentDocument(); 857 | 858 | if (document.getElementById('CSSViewer_block')) { 859 | return true; 860 | } 861 | 862 | return false; 863 | } 864 | 865 | /* 866 | * Enable CSSViewer 867 | */ 868 | CSSViewer.prototype.Enable = function() 869 | { 870 | var document = GetCurrentDocument(); 871 | var block = document.getElementById('CSSViewer_block'); 872 | 873 | if (!block){ 874 | block = this.CreateBlock(); 875 | document.body.appendChild(block); 876 | this.AddEventListeners(); 877 | 878 | return true; 879 | } 880 | 881 | return false; 882 | } 883 | 884 | /* 885 | * Disable CSSViewer 886 | */ 887 | CSSViewer.prototype.Disable = function() 888 | { 889 | var document = GetCurrentDocument(); 890 | var block = document.getElementById('CSSViewer_block'); 891 | 892 | if (block) { 893 | document.body.removeChild(block); 894 | this.RemoveEventListeners(); 895 | 896 | return true; 897 | } 898 | 899 | return false; 900 | } 901 | 902 | /* 903 | * Freeze CSSViewer 904 | */ 905 | CSSViewer.prototype.Freeze = function() 906 | { 907 | var document = GetCurrentDocument(); 908 | var block = document.getElementById('CSSViewer_block'); 909 | if ( block && this.haveEventListeners ) { 910 | this.RemoveEventListeners(); 911 | 912 | return true; 913 | } 914 | 915 | return false; 916 | } 917 | 918 | /* 919 | * Unfreeze CSSViewer 920 | */ 921 | CSSViewer.prototype.Unfreeze = function() 922 | { 923 | var document = GetCurrentDocument(); 924 | var block = document.getElementById('CSSViewer_block'); 925 | if ( block && !this.haveEventListeners ) { 926 | // Remove the red outline 927 | CSSViewer_current_element.style.outline = ''; 928 | this.AddEventListeners(); 929 | 930 | return true; 931 | } 932 | 933 | return false; 934 | } 935 | 936 | /* 937 | * Display the notification message 938 | */ 939 | function cssViewerInsertMessage( msg ) 940 | { 941 | var oNewP = document.createElement("p"); 942 | var oText = document.createTextNode( msg ); 943 | 944 | oNewP.appendChild(oText); 945 | oNewP.id = 'cssViewerInsertMessage'; 946 | oNewP.style.backgroundColor = '#b40000'; 947 | oNewP.style.color = '#ffffff'; 948 | oNewP.style.position = "absolute"; 949 | oNewP.style.top = '10px'; 950 | oNewP.style.left = '10px'; 951 | oNewP.style.zIndex = '100'; 952 | oNewP.style.padding = '3px'; 953 | 954 | // https://github.com/miled/cssviewer/issues/5 955 | // https://github.com/miled/cssviewer/issues/6 956 | // var beforeMe = document.getElementsByTagName("body"); 957 | // document.body.insertBefore( oNewP, beforeMe[0] ); 958 | 959 | // https://github.com/zchee/cssviewer/commit/dad107d27e94aabeb6e11b935ad28c4ff251f895 960 | document.body.appendChild(oNewP); 961 | } 962 | 963 | /* 964 | * Removes and element from the dom, used to remove the notification message 965 | */ 966 | function cssViewerRemoveElement(divid) 967 | { 968 | var n = document.getElementById(divid); 969 | 970 | if(n){ 971 | document.body.removeChild(n); 972 | } 973 | } 974 | 975 | /* 976 | * Copy current element CSS to Firefox console 977 | */ 978 | function cssViewerCopyCssToConsole(type) 979 | { 980 | if( 'el' == type ) return console.log( CSSViewer_element ); 981 | if( 'id' == type ) return console.log( CSSViewer_element.id ); 982 | if( 'tagName' == type ) return console.log( CSSViewer_element.tagName ); 983 | if( 'className' == type ) return console.log( CSSViewer_element.className ); 984 | if( 'style' == type ) return console.log( CSSViewer_element.style ); 985 | if( 'cssText' == type ) return console.log( document.defaultView.getComputedStyle(CSSViewer_element, null).cssText ); 986 | if( 'getComputedStyle' == type ) return console.log( document.defaultView.getComputedStyle(CSSViewer_element, null) ); 987 | if( 'simpleCssDefinition' == type ) return console.log( CSSViewer_element_cssDefinition ); 988 | } 989 | 990 | /* 991 | * Close css viewer on clicking 'esc' key 992 | * Freeze css viewer on clicking 'f' key 993 | */ 994 | function CssViewerKeyMap(e) { 995 | if( ! cssViewer.IsEnabled() ) 996 | return; 997 | 998 | // ESC: Close the css viewer if the cssViewer is enabled. 999 | if ( e.keyCode === 27 ){ 1000 | // Remove the red outline 1001 | CSSViewer_current_element.style.outline = ''; 1002 | cssViewer.Disable(); 1003 | } 1004 | 1005 | if( e.altKey || e.ctrlKey ) 1006 | return; 1007 | 1008 | // f: Freeze or Unfreeze the css viewer if the cssViewer is enabled 1009 | if ( e.keyCode === 70 ){ 1010 | if ( cssViewer.haveEventListeners ){ 1011 | cssViewer.Freeze(); 1012 | } 1013 | else { 1014 | cssViewer.Unfreeze(); 1015 | } 1016 | } 1017 | 1018 | // c: Show code css for selected element. 1019 | // window.prompt should suffice for now. 1020 | if ( e.keyCode === 67 ){ 1021 | window.prompt("Simple Css Definition :\n\nYou may copy the code below then hit escape to continue.", CSSViewer_element_cssDefinition); 1022 | } 1023 | } 1024 | 1025 | 1026 | /* 1027 | * CSSViewer entry-point 1028 | */ 1029 | cssViewer = new CSSViewer(); 1030 | 1031 | if ( cssViewer.IsEnabled() ){ 1032 | cssViewer.Disable(); 1033 | } 1034 | else{ 1035 | cssViewer.Enable(); 1036 | } 1037 | 1038 | // Set event handler for the CssViewer 1039 | document.onkeydown = CssViewerKeyMap; 1040 | -------------------------------------------------------------------------------- /src/manifest.json: -------------------------------------------------------------------------------- 1 | { "name":"CSSViewer", 2 | "manifest_version":2, 3 | "version":"1.1", 4 | "description":"A simple CSS property viewer. For Firefox Quantum", 5 | "icons":{"16":"img/16.png","22":"img/22.png","24":"img/24.png","32":"img/32.png","48":"img/48.png"}, 6 | "options_ui": { 7 | "page": "option.html", 8 | "browser_style": true 9 | }, 10 | "background":{"page":"background.html"}, 11 | "browser_action":{"default_icon":"img/16.png","default_title":"CSSViewer"}, 12 | "web_accessible_resources":["img/header.png","img/body.png","img/list.png","img/footer.png","img/bullet.png"], 13 | "permissions":["tabs","http://*/*","https://*/*","file://*/*","contextMenus"], 14 | "applications":{"gecko":{"id":"CSSViewer@quantum"}}} -------------------------------------------------------------------------------- /src/option.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 14 | 15 | 16 |
25 | CSSViewer Extension 1.126 |
27 | CSSViewer is a simple CSS property viewer for Firefox Quantum originally made by Nicolas Huon as a Firefox addon.
28 | 34 | ![]() How to use :36 |
Note that the menu will only show up when you enable CSSViewer and will only work on the page you're inspecting. Also, CSSViewer will only work on http, https and local pages. 53 | 54 |Privacy :55 |56 | In order to work properly, CSSViewer requires the permission to access to your history and website data. 57 | However, CSSViewer do not collect nor will ever transmit any of your private data. 58 | 59 | 60 | 61 | 62 |How to Uninstall :63 |
Changelog:71 |
72 | 1.0: 2018/06/06 - Initial version.
74 |
75 | 73 | Known Issues:76 |
77 | CSSViewer will not work in any opened tabs before installing it nor in the Mozilla Addons page.
80 |
81 | 78 | The style may break sometimes depending on the site you are surfing. 79 | 82 | 83 | 84 | 85 | CSSViewer automatically display this page when the extension is updated to a new version. 86 | 87 |88 | This Firefox extension is a straight port of the Chrome CSSViewer add-on with minor enhancements. Credits goes to the original developer and contributors. 89 | 90 | |
91 |