{"id":15655855,"url":"https://github.com/liuyueyi/chrome-coder","last_synced_at":"2026-05-05T05:35:01.552Z","repository":{"id":73356782,"uuid":"87617218","full_name":"liuyueyi/Chrome-Coder","owner":"liuyueyi","description":"Chrome Extension for base encode","archived":false,"fork":false,"pushed_at":"2017-04-08T07:50:10.000Z","size":95,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-05T04:07:42.734Z","etag":null,"topics":["chrome-extension","encoder-decoder","javascript","timestamp"],"latest_commit_sha":null,"homepage":null,"language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/liuyueyi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-08T07:45:53.000Z","updated_at":"2017-04-08T07:51:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"f3e22081-3968-4de8-aa58-0d1c63972919","html_url":"https://github.com/liuyueyi/Chrome-Coder","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liuyueyi%2FChrome-Coder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liuyueyi%2FChrome-Coder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liuyueyi%2FChrome-Coder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liuyueyi%2FChrome-Coder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/liuyueyi","download_url":"https://codeload.github.com/liuyueyi/Chrome-Coder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246266250,"owners_count":20749754,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chrome-extension","encoder-decoder","javascript","timestamp"],"created_at":"2024-10-03T13:00:39.998Z","updated_at":"2026-05-05T05:35:01.513Z","avatar_url":"https://github.com/liuyueyi.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"#Encoder\r\n\u003e 一个chrome扩展小工具，实现unicode/utf8/中文的转码, 实现日期和时间戳的互换\r\n\r\n## 简单说明\r\n\r\n目前的功能比较简单，主要实现编码转换 \u0026 时间戳\u0026日期互转\r\n\r\n### 1. utf8 / chinese\r\n\r\n```javascript\r\n// 中文转 utf8\r\nfunction chinese2Utf8(text) {\r\n    return text.replace(/[^\\u0000-\\u00FF]/g, function($0) {\r\n        return escape($0).replace(/(%u)(\\w{4})/gi, \"\u0026#x$2;\") });\r\n}\r\n\r\n// 中文转 utf8\r\nfunction utf82Chinese(text) {\r\n    return unescape(text.replace(/\u0026#x/g, '%u').replace(/;/g, ''));\r\n}\r\n```\r\n\r\n### 2. unicode / chinese\r\n\r\n```javascript\r\n// 汉字转unicode\r\nfunction chinese2Unicode(text) {\r\n    return text.replace(/([\\u4E00-\\u9FA5]|[\\uFE30-\\uFFA0])/g, function(newStr) {\r\n        return \"\\\\u\" + newStr.charCodeAt(0).toString(16);\r\n    });\r\n}\r\n\r\n\r\n// unicode 转中文\r\nfunction unicode2Chinese(text) {\r\n    return eval(\"'\" + text + \"'\");\r\n}\r\n```\r\n\r\n\r\n### 3. url 编码/解码\r\n\r\n```javascript\r\n// url 编码\r\nfunction encodeUrl(urlText) {\r\n    return encodeURIComponent(urlText);\r\n}\r\n\r\n\r\n// url 解码\r\nfunction decodeUrl(urlText) {\r\n    return decodeURIComponent(urlText);\r\n}\r\n```\r\n\r\n\r\n### 4. 时间戳转换\r\n\r\n```javascript\r\n// 时间戳转日期\r\nfunction time2date(timestamp) {\r\n    var localDate =  new Date(parseInt(timestamp) * 1000);\r\n    var result = localDate.getFullYear() + \"-\" + (localDate.getMonth() + 1) + \"-\" + localDate.getDate() + \" \" + localDate.getHours() + \":\" + localDate.getMinutes() + \":\" + localDate.getSeconds();\r\n    return result;\r\n}\r\n\r\n// 日期转时间戳\r\n// 日期格式 2014-07-10 10:21:12\r\nfunction date2time(dateTime) {\r\n    if (dateTime.indexOf(\":\") \u003c 0) {\r\n        dateTime += \" 00:00:00\";\r\n    };\r\n    return Date.parse(new Date(dateTime)) / 1000;\r\n}\r\n```\r\n\r\n说明下日期转时间戳时，如果只传入了日期，利用  `new Date(dateTime)` 生成的时间会是8点， 时区的问题，js我也不会玩，就用最low的方法兼容了下\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliuyueyi%2Fchrome-coder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliuyueyi%2Fchrome-coder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliuyueyi%2Fchrome-coder/lists"}