Last active
March 10, 2017 09:40
-
-
Save firedfox/fbb3e17e419b57308018 to your computer and use it in GitHub Desktop.
Revisions
-
firedfox revised this gist
May 19, 2015 . 1 changed file with 10 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,14 @@ // example: // phantomjs getComputedStyle.js "http://www.iqiyi.com/" ".usrTxGeneral-box_hover" "position,display,visibility,overflow" var TIMEOUT = 60 * 1000; var webPage = require('webpage'); var system = require('system'); var page = webPage.create(); page.settings.loadImages = false; var args = system.args; if (args.length < 4) { console.log('usage: phantomjs getComputedStyle.js url elementSelector styleNames'); @@ -15,8 +17,8 @@ if (args.length < 4) { var url = args[1]; var elementSelector = args[2]; var styleNames = args[3].split(','); var getStyles = function(status) { var styleValues = page.evaluate(function(elementSelector, styleNames) { var element = document.querySelector(elementSelector); var computedStyle = window.getComputedStyle(element); @@ -28,4 +30,7 @@ page.open(url, function(status) { }, elementSelector, styleNames); console.log(styleValues.join('\t')); phantom.exit(); }; page.open(url, getStyles); setTimeout(getStyles, TIMEOUT); -
firedfox revised this gist
May 19, 2015 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,23 +9,23 @@ page.settings.loadImages = false; var args = system.args; if (args.length < 4) { console.log('usage: phantomjs getComputedStyle.js url elementSelector styleNames'); phantom.exit(); } var url = args[1]; var elementSelector = args[2]; var styleNames = args[3].split(','); page.open(url, function(status) { var styleValues = page.evaluate(function(elementSelector, styleNames) { var element = document.querySelector(elementSelector); var computedStyle = window.getComputedStyle(element); var styleValues = []; styleNames.forEach(function(styleName) { styleValues.push(computedStyle.getPropertyValue(styleName)); }); return styleValues; }, elementSelector, styleNames); console.log(styleValues.join('\t')); phantom.exit(); }); -
firedfox revised this gist
May 19, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,7 @@ page.settings.loadImages = false; var args = system.args; if (args.length < 4) { console.log('usage: phantomjs getComputedStyle.js url element styleNames'); phantom.exit(); } var url = args[1]; -
firedfox revised this gist
May 13, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ // example: // phantomjs getComputedStyle.js "http://www.iqiyi.com/" ".usrTxGeneral-box_hover" "position,display,visibility,overflow" var webPage = require('webpage'); var system = require('system'); -
firedfox revised this gist
May 13, 2015 . 1 changed file with 12 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ // example: // phantomjs getComputedStyle.js "http://www.iqiyi.com/" ".usrTxGeneral-box_hover" "position,display,font-family" var webPage = require('webpage'); var system = require('system'); @@ -9,18 +9,23 @@ page.settings.loadImages = false; var args = system.args; if (args.length < 4) { console.log('usage: phantomjs getComputedStyle.js url elementId styleNames'); phantom.exit(); } var url = args[1]; var elementId = args[2]; var styleNames = args[3].split(','); page.open(url, function(status) { var styleValues = page.evaluate(function(elementId, styleNames) { var element = document.querySelector(elementId); var computedStyle = window.getComputedStyle(element); var styleValues = []; styleNames.forEach(function(styleName) { styleValues.push(computedStyle.getPropertyValue(styleName)); }); return styleValues; }, elementId, styleNames); console.log(styleValues.join('\t')); phantom.exit(); }); -
firedfox revised this gist
May 13, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ // example: // phantomjs getComputedStyle.js "http://www.iqiyi.com/" ".usrTxGeneral-box_hover" "position" var webPage = require('webpage'); var system = require('system'); -
firedfox revised this gist
May 13, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ // example: // phantomjs getComputedStyle.js "http://www.iqiyi.com/" ".navTopNew" "position" var webPage = require('webpage'); var system = require('system'); -
firedfox revised this gist
May 12, 2015 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ // example: // phantomjs getComputedStyle.js 'http://family.baidu.com/' '.item:last-child' 'font-size' var webPage = require('webpage'); var system = require('system'); @@ -17,10 +17,10 @@ var elementId = args[2]; var styleName = args[3]; page.open(url, function(status) { var styleValue = page.evaluate(function(elementId, styleName) { var element = document.querySelector(elementId); return window.getComputedStyle(element).getPropertyValue(styleName); }, elementId, styleName); console.log(styleValue); phantom.exit(); }); -
firedfox revised this gist
May 12, 2015 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,6 @@ // example: // phantomjs getComputedStyle.js 'http://family.baidu.com/' '.item' 'fontSize' var webPage = require('webpage'); var system = require('system'); -
firedfox created this gist
May 12, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ var webPage = require('webpage'); var system = require('system'); var page = webPage.create(); page.settings.loadImages = false; var args = system.args; if (args.length < 4) { console.log('usage: phantomjs getComputedStyle.js url elementId styleName'); phantom.exit(); } var url = args[1]; var elementId = args[2]; var styleName = args[3]; page.open(url, function(status) { var styleValue = page.evaluate(function(elementId) { var element = document.querySelector(elementId); return window.getComputedStyle(element); }, elementId); console.log(styleValue[styleName]); phantom.exit(); });